Blog dans lequel je note comme aide-mémoire les trucs et astuces que j'ai utilisés pour configurer selon mes besoins mes machines sous Linux Ubuntu Raspbian Macosx Windows.
Rechercher dans ce blog
mercredi 15 juillet 2026
lundi 25 mai 2026
See imap namespace
See imap namespace
"see the folders structure exactly as it is on the server" can be surprisingly complex when it comes to IMAP.
Connect to the IMAP server using some SSL/TLS-capable variant of Telnet:
- gnutls-cli mail.example.com -p imaps
- openssl s_client -connect mail.example.com:imaps
Each command has to be prefixed with a "tag" (allowing a client to send multiple commands and distinguish between interleaved responses). When typing commands manually, you can just use something like a as the tag for all commands, e.g. a login.
To log in with a password, use LOGIN:
==> a login "my_username" "the_password"
<-- a OK
IMAP has a feature called namespaces, which allows the server to combine several separate folder trees into one (e.g. your personal folders plus some group-shared folders).
List the namespaces using NAMESPACE:
==> a namespace
<-- * NAMESPACE (("" "/")) NIL NIL
<-- a OK Namespace completed (0.001 + 0.000 secs).
Here the server has just a single "" namespace, with "/" as the folder separator ("." is traditional but nowadays less common). Importantly, as far as I know, each namespace can have a different separator – so a folder hierarchy could actually be a mix of / and . separated levels.
In your case, it might be that the "" namespace contains your folders in the server's standard storage, while the "mail/" namespace might be a view into the plain ~/Mail/ directory on your NFS homedir.
(If that's the case, then it is possible that Thunderbird displays mail/ as gray because it is unselectable due to storage restrictions – old-style "mbox"-format storage uses an ordinary file to hold a whole IMAP folder, so it cannot be both a file and a directory at the same time.)
List all folders in the "" namespace using LIST:
==> a list "" "*"
<-- * LIST (\HasNoChildren) "/" INBOX
<-- * LIST (\HasChildren \UnMarked \Archive) "/" Archive
<-- * LIST (\HasChildren \UnMarked) "/" Archive/Work
<-- * LIST (\HasChildren \UnMarked) "/" Historic
...
<-- a OK List completed (0.001 + 0.000 secs).
Here the first parameter is the starting path ("" means list everything, while e.g. "Archive" would only list children of that folder). The second parameter is the filter pattern ("*" lists everything, recursively, while "%" only lists one level down).
Modern servers support tagging certain folders as "special-use", e.g. the drafts folder would be tagged \Drafts no matter its actual name, and Thunderbird would always recognize it as the drafts folder. This is sometimes changeable via proprietary webmail, but usually not via IMAP itself.
You can also list subscribed folders using LSUB (using the same syntax):
==> a lsub "" "*"
Most IMAP clients use subscriptions to decide what folders to display in the UI, and/or which folders to poll for new messages. Unsubscribing a folder effectively hides it from Thunderbird's tree. Sometimes you can end up with ghost subscriptions (a folder that no longer exists is still subscribed and shows up in Thunderbird). You can use UNSUBSCRIBE to remove those.
https://www.atmail.com/blog/imap-commands/
STARTTLS
This command instructs the server that the client wishes to encrypt the session now. This command may only be issued if the server advertised that STARTTLS is available and supported. If a successful key negotiation results after this command is issued, then the session is encrypted and IMAP commands continue.
Here is an example of connecting to an IMAP server (with netcat) and issuing the STARTTLS command:
| 1 2 3 4 | $ nc zeus.p 143 * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] IMAP/POP3 ready - zeus c1 STARTTLS c1 OK Begin TLS negotiation now. |
Here is openssl’s s_client utility performing a successful TLS connection:
| 1 2 3 4 5 6 7 | $ openssl s_client -connect zeus.p:143 -starttls imap -crlf -quiet depth=0 OU = IMAP server, CN = imap.example.com, emailAddress = postmaster@example.com verify error:num=18:self signed certificate verify return:1 depth=0 OU = IMAP server, CN = imap.example.com, emailAddress = postmaster@example.com verify return:1 . OK Pre-login capabilities listed, post-login capabilities have more. |
AUTHENTICATE
This command advises the server that the client wants to initiate a SASL authentication mechanism to prove its identity. The client may only select a SASL method advertised by the server – which is shown in the response to the command CAPABILITY.
This is an example from our IMAP 101 post:
| 1 2 3 4 5 6 7 8 9 10 | $ telnet imap-us.atmailcloud.com 143 Trying 204.145.97.25... Connected to imap-us.atmailcloud.com. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] IMAP/POP3 ready - us11-012mip a authenticate login + VXNlcm5hbWU6 c29tZXVzZXJAZXhhbXBsZS5hdG1haWxjbG91ZC5jb20= + UGFzc3dvcmQ6 TXlfUEBzc3dvcmQx a OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE NOTIFY SPECIAL-USE QUOTA] Logged in |
LOGIN
This command advises the server that the client wants to login with a username and password to prove its identity.
Here is the example from our IMAP 101 post:
| 1 2 3 4 5 6 7 | $ telnet imap-us.atmailcloud.com 143 Trying 204.145.97.26... Connected to imap-us.atmailcloud.com. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] IMAP/POP3 ready - us11-011mip A1 login someuser@example.atmailcloud.com My_P@ssword1 A1 OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE NOTIFY SPECIAL-USE QUOTA] Logged in |
Client Commands: Authenticated State
Once a client is authenticated to the server, the following set of commands become accessible.
SELECT
This command instructs the server that the client now wishes to select a particular mailbox or folder, and any commands that relate to a folder should assume this folder as the target of that command. For example, an INBOX or a subfolder such as, “To Do.This Weekend”. Once a mailbox is selected, the state of the connection becomes “Selected”.
This is an example from our IMAP 101 post:
| 1 2 3 4 5 6 7 8 9 10 | g21 SELECT "INBOX" * FLAGS (Answered Flagged Deleted Seen Draft) * OK [PERMANENTFLAGS (Answered Flagged Deleted Seen Draft *)] Flags permitted. * 4 EXISTS * 0 RECENT * OK [UNSEEN 2] First unseen. * OK [UIDVALIDITY 1536750617] UIDs valid * OK [UIDNEXT 9] Predicted next UID * OK [HIGHESTMODSEQ 11] Highest g21 OK [READ-WRITE] Select completed (0.000 + 0.000 secs). |
EXAMINE
This command does the exact same thing as SELECT, except that it selects the folder in read-only mode, meaning that no changes can be effected on the folder.
Here is an example from RFC 3501:
| 1 2 3 4 5 6 7 8 9 | A932 EXAMINE blurdybloop * 17 EXISTS * 2 RECENT * OK [UNSEEN 8] Message 8 is first unseen * OK [UIDVALIDITY 3857529045] UIDs valid * OK [UIDNEXT 4392] Predicted next UID * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS ()] No permanent flags permitted A932 OK [READ-ONLY] EXAMINE completed |
CREATE
This command created a new folder.
This example is from our Advanced IMAP post:
| 1 2 3 4 5 6 7 8 | c CREATE work c OK Create completed (0.002 + 0.000 + 0.001 secs). k2 LIST "" "*" * LIST (\HasNoChildren \Trash) "." Trash * LIST (\HasNoChildren) "." folder1 * LIST (\HasNoChildren) "." work * LIST (\HasNoChildren) "." INBOX k2 OK List completed (0.001 + 0.000 secs). |
DELETE
This command deletes the named mailbox or folder.
We haven’t covered this command in either our IMAP 101 or Advanced IMAP posts, so here is an example from RFC 3501:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | A682 LIST "" * * LIST () "/" blurdybloop * LIST (\Noselect) "/" foo * LIST () "/" foo/bar A682 OK LIST completed A683 DELETE blurdybloop A683 OK DELETE completed A684 DELETE foo A684 NO Name "foo" has inferior hierarchical names A685 DELETE foo/bar A685 OK DELETE Completed A686 LIST "" * * LIST (\Noselect) "/" foo A686 OK LIST completed A687 DELETE foo A687 OK DELETE Completed |
RENAME
This command renames a mailbox or folder from one name to a new name.
Again, another command we haven’t covered in our previous posts.
An example from RFC 3501:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | A682 LIST "" * * LIST () "/" blurdybloop * LIST (\Noselect) "/" foo * LIST () "/" foo/bar A682 OK LIST completed A683 RENAME blurdybloop sarasoop A683 OK RENAME completed A684 RENAME foo zowie A684 OK RENAME Completed A685 LIST "" * * LIST () "/" sarasoop * LIST (\Noselect) "/" zowie * LIST () "/" zowie/bar A685 OK LIST completed |
SUBSCRIBE
OK, this command needs a little explanation. In IMAP you have a list of folders (also called mailboxes), and these mailboxes may be: yours, the logged in user; or they might be other users who have given you access; or they might be publicly accessible folders, for anyone to access.
However, you may find that a subset of these folders are more interesting to you than others and therefore you wish to “subscribe” to them and only be notified of updates and changes to those folders.
When you SUBSCRIBE to a folder, that folder will be returned when the client issues an LSUB command (i.e. list subscribed folders only) – this means the client then only needs to poll for changes in the folders that you are interested in, rather than all of the folders you might be able to access.
Here is an example of the subscribe command in action from RFC 3501. In this case, a publicly available folder is being subscribed to:
| 1 2 | A002 SUBSCRIBE #news.comp.mail.mime A002 OK SUBSCRIBE completed |
UNSUBSCRIBE
No prizes for guessing what this command does. Yep, it’s the opposite of SUBSCRIBE above. You are telling the server that you are no longer interested in this folder, and please do not return this folder in response to the LSUB command.
The example from RFC 3501:
| 1 2 | A002 UNSUBSCRIBE #news.comp.mail.mime 002 OK UNSUBSCRIBE completed |
LIST
This command will list all folders/mailboxes that you are entitled to list on the server, whether it be your own folders, another user’s, or publicly available folders.
This command does take two possible arguments. The first (known as the “reference name”) indicates under what folder hierarchy you’d like to limit the list to. The second argument (known as the “mailbox name”) can contain wildcards to match names under the provided hierarchy.
Here is an example from our IMAP 101 post that lists all the folders under the users INBOX:
| 1 2 3 4 5 6 7 8 | A1 list "INBOX/" "*" * LIST (HasNoChildren) "/" INBOX/some_other_folder * LIST (HasNoChildren UnMarked Archive) "/" INBOX/Archive * LIST (HasNoChildren UnMarked Sent) "/" INBOX/Sent * LIST (HasNoChildren Marked Trash) "/" INBOX/Trash * LIST (HasNoChildren Marked Junk) "/" INBOX/Spam * LIST (HasNoChildren UnMarked Drafts) "/" INBOX/Drafts A1 OK List completed (0.000 + 0.000 secs). |
Compare that to this example taken from RFC 3501, which lists all folders under ~/Mail but not subfolders of those folders (the % characters causes this behaviour):
| 1 2 3 4 | A202 LIST ~/Mail/ % * LIST (\Noselect) "/" ~/Mail/foo * LIST () "/" ~/Mail/meetings A202 OK LIST completed |
LSUB
As discussed above under the SUBSCRIBE command, the LSUB command will act the same as LIST but only return folders that have been subscribed to by the user.
Here is the example from RFC 3501, that uses both reference names and mailbox names/patterns (as discussed above under the LIST command):
| 1 2 3 4 5 6 7 | A002 LSUB "#news." "comp.mail.*" * LSUB () "." #news.comp.mail.mime * LSUB () "." #news.comp.mail.misc A002 OK LSUB completed A003 LSUB "#news." "comp.%" * LSUB (\NoSelect) "." #news.comp.mail A003 OK LSUB completed |
STATUS
This command requests the status of the folder provided. This allows the status of a folder not currently selected to be updated in the client. The client must advise the server what attributes of the folder that it is interested in, with possible values being:
- MESSAGES: The number of messages in the mailbox.
- RECENT: The number of messages with the \Recent flag set.
- UIDNEXT: The next unique identifier value of the mailbox.
- UIDVALIDITY: The unique identifier validity value of the mailbox.
- UNSEEN: The number of messages which do not have the \Seen flag set.
We have not covered this command in any of our previous posts, so here is the example from RFC 3501:
| 1 2 3 | A042 STATUS blurdybloop (UIDNEXT MESSAGES) * STATUS blurdybloop (MESSAGES 231 UIDNEXT 44292) A042 OK STATUS completed |
APPEND
This command allows a message to be appended to a specified mailbox. This isn’t a copy/move command, you must supply a full message body to append.
Here is the example from our Advanced IMAP post – to be clear the number inside the curly brackets (i.e. {89} below) is the number of octets to expect for the message:
| 1 2 3 4 5 6 | a1 APPEND "work.due today" {89} + OK Subject: Send the weekly report Remember to send the weekly report to THE BOSS TODAY!! a1 OK [APPENDUID 1548379804 2] Append completed (0.007 + 4.391 + 0.005 secs). |
Client Commands: Authenticated State
Once a client selects (or EXAMINE’s) a folder, the following command becomes available to the client, in addition to the authenticated commands.
CHECK
This is a seldom used command. It requests a “checkpoint” on the server. Which means that the server is instructed to complete some housekeeping on the mailbox – very weird for a client to request this, and we’ve never seen a client call it, but it exists… for some reason, which can only possibly be implementation dependant.
An exciting example from RFC 3501:
| 1 2 | FXXZ CHECK FXXZ OK CHECK Completed |
CLOSE
This closes the currently selected mailbox, and as a side-effect, an expunge is run on the mailbox (i.e. all messages marked as \Deleted are deleted properly). After this command returns, the client is no longer in the “selected” state and returns to the “authenticated” state.
Here is the example from RFC 3501:
| 1 2 | A341 CLOSE A341 OK CLOSE completed |
EXPUNGE
This command instructs the server to permanently delete messages that have the \Deleted flag set on them from the currently selected folder.
Note: This does not mean “move to trash”. It means to really, properly, and finally delete.
Here is an example from our IMAP 101 post:
| 1 2 3 4 5 6 | d store 2 +FLAGS (Deleted) * 2 FETCH (FLAGS (Deleted Seen)) d OK Store completed (0.001 + 0.000 secs). e expunge * 2 EXPUNGE e OK Expunge completed. |
SEARCH
The search command is a powerful command that probably warrants an entire future post to itself. With the rise of mobile clients, it is a command that is being leveraged more than ever. Mobile clients don’t have the capacity to store and process mail on the device itself, and offloading this work onto a server saves precious battery life.
In a nutshell, you can provide various search terms to the server and any messages that match, in the currently selected folder, will be returned. One limitation of the command is that when multiple search terms are specified, they are considered “AND” terms by default, but you can select only two terms to “OR”, and there is no complex logic grouping (i.e. bracketing of terms) – so it’s rather simple in that regard.
Here is a rundown of all the possible criteria that can be specified:
- ALL: All messages in the mailbox.
- ANSWERED: Messages with the \Answered flag set.
- BCC <string>: Messages that contain the specified string in the envelope structure’s BCC field.
- BEFORE <date>: Messages whose internal date (disregarding time and timezone) is earlier than the specified date.
- BODY <string>: Messages that contain the specified string in the body of the message.
- CC <string>: Messages that contain the specified string in the envelope structure’s CC field.
- DELETED: Messages with the \Deleted flag set.
- DRAFT: Messages with the \Draft flag set.
- FLAGGED: Messages with the \Flagged flag set.
- FROM <string>: Messages that contain the specified string in the envelope structure’s FROM field.
- HEADER <field-name> <string>: Messages that have a header with the specified field-name and which contain the specified string in the text of the header (i.e. what comes after the colon). If the string to search is zero-length, this matches all messages that have a header line with the specified field-name, regardless of the contents.
- KEYWORD <flag>: Messages with the specified keyword flag set.
- LARGER <n>: Messages with a size larger than the specified number of octets.
- NEW: Messages that have the \Recent flag set but not the \Seen flag.
- NOT <search-key>: Messages that do not match the specified search key.
- OLD: Messages that do not have the \Recent flag set.
- ON <date>: Messages whose internal date (disregarding time and timezone) is within the specified date.
- OR <search-key1> <search-key2>: Messages that match either search key.
- RECENT: Messages that have the \Recent flag set.
- SEEN: Messages that have the \Seen flag set.
- SENTBEFORE <date>: Messages whose Date: header (disregarding time and timezone) is earlier than the specified date.
- SENTON <date>: Messages whose Date: header (disregarding time and timezone) is within the specified date.
- SENTSINCE <date>: Messages whose Date: header (disregarding time and timezone) is within or later than the specified date.
- SINCE <date>: Messages whose internal date (disregarding time and timezone) is within or later than the specified date.
- SMALLER <n>: Messages with a size smaller than the specified number of octets.
- SUBJECT <string>: Messages that contain the specified string in the envelope structure’s SUBJECT field.
- TEXT <string>: Messages that contain the specified string in the header or body of the message.
- TO <string>: Messages that contain the specified string in the envelope structure’s TO field.
- UID <sequence set>: Messages with unique identifiers corresponding to the specified unique identifier set. Sequence set ranges are permitted.
- UNANSWERED: Messages that do not have the \Answered flag set.
- UNDELETED: Messages that do not have the \Deleted flag set.
- UNDRAFT: Messages that do not have the \Draft flag set.
- UNFLAGGED: Messages that do not have the \Flagged flag set.
- UNKEYWORD <flag>: Messages that do not have the specified keyword flag set.
- UNSEEN: Messages that do not have the \Seen flag set.
Here is the example we used in our Advanced IMAP post, where we search for unseen messages with “crash” in the subject. Then we “see” one of the messages and then perform the search again and notice that it no longer appears in the search result list:
| 1 2 3 4 5 6 7 8 9 10 11 | s2 SEARCH UNSEEN HEADER SUBJECT "crash" * SEARCH 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 s2 OK Search completed (0.001 + 0.000 secs). f FETCH 15 BODY[HEADER.FIELDS (SUBJECT)] * 15 FETCH (FLAGS (\Seen) BODY[HEADER.FIELDS (SUBJECT)] {18} Subject: crash ) f OK Fetch completed (0.001 + 0.000 secs). s3 SEARCH UNSEEN HEADER SUBJECT "crash" * SEARCH 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 s3 OK Search completed (0.002 + 0.000 + 0.001 secs). |
FETCH
This command allows a client to fetch messages from a folder, and it is one of the most widely used IMAP commands.
You may specify which messages you wish to fetch, and even which messages parts; you do not have to fetch the entire message. This one command is probably the “killer feature” of IMAP, one of the main reasons it exists; it allows clients to interact in a sophisticated way with the IMAP server.
Here is a list of all the message parts (and defined macros representing pre-defined messages parts) you can fetch:
- ALL: Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
- FAST: Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE)
- FULL: Macro equivalent to: (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)
- BODY: Non-extensible form of BODYSTRUCTURE.
- BODY[<section>]<<partial>>: The text of a particular body section. The section specification is a set of zero or more part specifiers delimited by periods. A part specifier is either a part number or one of the following: HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, MIME, and TEXT. An empty section specification refers to the entire message, including the header. You may even select only parts of a multipart MIME message and even specific octets within that part, see RFC 3501#section-6.4.5 for more details.
- BODY.PEEK[<section>]<<partial>>: An alternate form of BODY[<section>] that does not implicitly set the \Seen flag.
- BODYSTRUCTURE: The MIME body structure of the message. This is computed by the server by parsing the MIME header fields in the header and body MIME headers.
- ENVELOPE: The envelope structure of the message. This is computed by the server by parsing the message header into the component parts, defaulting various fields as necessary.
- FLAGS: The flags that are set for this message.
- INTERNALDATE: The internal date of the message.
- RFC822: Functionally equivalent to BODY[], differing in the syntax of the resulting untagged FETCH data in that the full RFC822 message is returned.
- RFC822.HEADER: Functionally equivalent to BODY.PEEK[HEADER], with RFC822 header syntax returned.
- RFC822.SIZE: The size of the message.
- RFC822.TEXT: Functionally equivalent to BODY[TEXT], differing in the syntax of the resulting untagged FETCH data as RFC822.TEXT is returned.
- UID: The unique identifier for the message.
Here is an example from our IMAP 101 post where we only fetch the Subject from the first four messages in a folder:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | f fetch 1:4 (BODY[HEADER.FIELDS (Subject)]) * 1 FETCH (BODY[HEADER.FIELDS (SUBJECT)] {27} Subject: Test message 1 ) * 2 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT)] {27} Subject: Test message 3 ) * 3 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT)] {27} Subject: Test message 5 ) * 4 FETCH (FLAGS (Seen) BODY[HEADER.FIELDS (SUBJECT)] {27} Subject: Test Message 6 ) f OK Fetch completed (0.002 + 0.000 secs). |
COPY
This message copies a message from the currently selected folder to a different folder, and preserves all flags and date information about the message.
Here is the example from our Advanced IMAP post – that post provides a more complete example:
| 1 2 | c1 COPY 10 "work.due today" c1 OK [COPYUID 1548379804 17 1] Copy completed (0.007 + 0.000 + 0.006 secs). |
UID
This is an interesting command, in that it is a modifier to other commands (namely COPY, FETCH, STORE and SEARCH). It instructs the server to use UIDs as arguments or results, rather than message sequence numbers (as is the default).
A sequence number references a message in that specific IMAP session, and the sequence numbers of messages may change between sessions, whereas UIDs remain constant for every message whilst the UIDVALIDITY flag for a folder remains unchanged.
We detail this further in our Advanced IMAP post. Here is an example from that post:
| 1 2 3 4 5 | w UID STORE 10 +FLAGS (a-funny-flag) * FLAGS (\Answered \Flagged \Deleted \Seen \Draft some-flag a-different-flag a-funny-flag) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft some-flag a-different-flag a-funny-flag \*)] Flags permitted. * 3 FETCH (UID 10 FLAGS (a-funny-flag)) w OK Store completed (0.004 + 0.000 + 0.003 secs). |
This wraps up all of the IMAP client commands defined in RFC 3501, however a number of extensions have been defined by errata RFC’s, which I will detail below.
Errata RFC IMAP Commands
A number of additions to the standard IMAP client commands have been defined, so we will give a quick overview of these too:
RFC 4314
RFC 4314 here as it is a commonly implemented extension to IMAP, as it enables administering rights to folders to other users (i.e. if you wanted to give permission to the same folder to a collection of people, and each of those people to have a different set of permissions).
It is important to understand the permission characters and their meaning, so I detail these here (as found in the RFC):
- l: Lookup (mailbox is visible to LIST/LSUB commands, and you may SUBSCRIBE to the mailbox)
- r: Read (SELECT the mailbox, perform STATUS)
- s: Keep seen/unseen information across sessions (set or clear \SEEN flag via STORE, also set \SEEN during APPEND/COPY/FETCH BODY[…])
- w: Write (set or clear flags other than \SEEN and \DELETED via STORE, also set them during APPEND/COPY)
- i: Insert (perform APPEND, COPY into mailbox)
- p: Post (send mail to submission address for mailbox, not enforced by IMAP4 itself but rather the implementation)
- c: Create/write (create and in some cases delete folders and subfolders and messages in the folders; this is obsoleted and is replaced by ‘k’ and ‘x’ and ‘t’)
- k: Create mailboxes (CREATE new sub-mailboxes in any implementation-defined hierarchy, parent mailbox for the new mailbox name in RENAME)
- d: Delete (delete mailboxes and subfolders, and messages; this is obsoleted and is replaced by ‘k’ and ‘x’ and ‘t’)
- x: Delete mailbox (DELETE mailbox, old mailbox name in RENAME)
- t: Delete messages (set or clear \DELETED flag via STORE, set \DELETED flag during APPEND/COPY)
- e: Perform EXPUNGE and expunge as a part of CLOSE
- a: Administer (perform SETACL/DELETEACL/GETACL/LISTRIGHTS)
Here are the associated IMAP commands:
SETACL
The SETACL command changes the access control list on the specified mailbox, so that the specified user is granted permissions as specified.
Here is an example from the RFC:
| 1 2 3 4 5 6 7 8 | A001 GETACL INBOX/Drafts * ACL INBOX/Drafts Fred rwipslxetad Chris lrswi A001 OK Getacl complete A002 SETACL INBOX/Drafts Chris +cda A002 OK Setacl complete A003 GETACL INBOX/Drafts * ACL INBOX/Drafts Fred rwipslxetad Chris lrswicdakxet A003 OK Getacl complete |
DELETEACL
The DELETEACL command removes any <identifier/user,rights> pair for the specified identifier/username from the access control list for the specified mailbox.
An example from the RFC:
| 1 2 3 4 5 6 7 8 | B001 getacl INBOX * ACL INBOX Fred rwipslxetad -Fred wetd $team w B001 OK Getacl complete B002 DeleteAcl INBOX Fred B002 OK Deleteacl complete B003 GETACL INBOX * ACL INBOX -Fred wetd $team w B003 OK Getacl complete |
GETACL
The GETACL command returns the access control list for the mailbox.
There are examples of this IMAP command in the previous two commands.
LISTRIGHTS
The LISTRIGHTS command takes a mailbox name and a username, and returns information about what rights can be granted to the user in the ACL for the mailbox.
Here is an example from the RFC:
| 1 2 3 | a001 LISTRIGHTS ~/Mail/saved smith * LISTRIGHTS ~/Mail/saved smith la r swicdkxte a001 OK Listrights completed |
MYRIGHTS
The MYRIGHTS command returns the set of rights that the logged in user has to a mailbox.
An example from the RFC:
| 1 2 3 | A003 MYRIGHTS INBOX * MYRIGHTS INBOX rwiptsldaex A003 OK Myrights complete |
RFC 4466
RFC 4466 outlines some extensions to the standard IMAP commands. Specifically, extensions to the commands SELECT/EXAMINE, CREATE, RENAME, FETCH, STORE, APPEND and SEARCH commands. This blog post is not going to detail these command extensions, but I invite you to read RFC 4466 if you think that these might be interesting to you.
RFC 4469
RFC 4469 introduces an extension to the APPEND command that allows the client to create a message on the server that can include the text of messages (or parts of messages) that already exist on the server, without having to FETCH them and APPEND them back to the server.
Here is an example from that RFC, which demonstrates how a CATENATE client can replace an attachment in a draft message, without the need to download it to the client and upload it back:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | A003 APPEND Drafts (\Seen \Draft $MDNSent) CATENATE (URL "/Drafts;UIDVALIDITY=385759045/;UID=20/;section=HEADER" TEXT {42} + Ready for literal data --------------030308070208000400050907 URL "/Drafts;UIDVALIDITY=385759045/;UID=20/;section=1.MIME" URL "/Drafts;UIDVALIDITY=385759045/;UID=20/;section=1" TEXT {42} + Ready for literal data --------------030308070208000400050907 URL "/Drafts;UIDVALIDITY=385759045/;UID=30" TEXT {44} + Ready for literal data --------------030308070208000400050907-- ) A003 OK catenate append completed |
RFC 5032
RFC 5032 exposes two new search keys for the IMAP search command, OLDER and YOUNGER, each of which takes a non-zero integer argument corresponding to a time interval in seconds. The server calculates the time of interest by subtracting the time interval that the client presents, from the current date and time of the server. The server then either returns messages older or younger than the resultant time and date, depending on the search key used.
Here is an example from that RFC:
| 1 2 | a1 SEARCH UNSEEN YOUNGER 259200 a1 * SEARCH 4 8 15 16 23 42 |
RFC 5182
RFC 5182 introduces the ability to reference messages that were a result of a search operation in other commands. As the RFC itself states, “many IMAP clients use the result of a SEARCH command as the input to perform another operation, for example, fetching the found messages, deleting them, or copying them to another mailbox. This can be achieved using standard IMAP operations described in RFC 3501; however, this would be suboptimal”.
Allowing commands to reference return results from a search command particularly lends itself to command pipelining, as demonstrated in this example from the RFC, where the client is pipelining the search and fetch commands that only act on interesting messages. The “$” symbol means “the results of the last saved search command”:
| 1 2 3 4 5 6 7 | A282 SEARCH RETURN (SAVE) FLAGGED SINCE 1-Feb-1994 NOT FROM "Smith" A283 FETCH $ (UID INTERNALDATE FLAGS RFC822.HEADER) A282 OK SEARCH completed * 2 FETCH (UID 14 ... * 84 FETCH (UID 100 ... * 882 FETCH (UID 1115 ... A283 OK completed |
RFC 8437
RFC 8437 introduces a new command, UNAUTHENTICATE, which serves to return the connection back to the “unauthenticated” state. Under the basic IMAP standard, a client is required to drop a connect and reconnect, but using this extension, a connection may be maintained and be reauthenticated, perhaps as a completely different user.
A small example of what the syntax probably looks like (I say ‘probably’ because I have never seen this command in the wild, nor could I find a server that implements it) might be:
| 1 2 3 | g456 unauthenticate g456 OK unauthenticated * OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE AUTH=PLAIN AUTH=LOGIN] IMAP/POP3 ready - my server |
jeudi 14 novembre 2024
Create Windows 11/10 Bootable USB Installation Media in Command Prompt from iso file
recopié sans les screenshots de :
https://www.elevenforum.com/t/create-windows-11-bootable-usb-installation-media.750/
Certaines étapes ne fonctionnent pas si le disque est GPT. Notamment la partition EFI doit être montée en sélectionnant dans diskpart la partition et en lui assignant une lettre. Mais cette partition reste inaccessible dans l'explorer. Il faut copier les fichiers en ligne de commande.
1 If you have not already, you will need to download a Windows 11 ISO file.
2 Connect the 8 GB or larger USB flash drive.
3 Open an elevated Windows Terminal, and select Windows PowerShell or Command Prompt.
4 Type diskpart into the elevated terminal, and press Enter.
5 Type list disk into the elevated terminal, press Enter, and make note of the Disk
6 Type select disk # into the elevated terminal, and press Enter.
Je vérifie que le disk est bien sélectionné histoire de ne pas faire un clean sur le disque principal...
list disk
N° disque Statut Taille Libre Dyn GPT
--------- ------------- ------- ------- --- ---
Disque 0 En ligne 167 G octets 100 M octets *
* Disque 1 En ligne 57 G octets 0 octets
7 Type clean into the elevated terminal, and press Enter.
Je reçois après le clean :
Diskpart a rencontré une erreur : Accès refusé.
Pour plus d’informations, voir le journal d’événements système.
list partition
Il n’y a pas de partitions à afficher sur ce disque.
detail disk
Lexar USB Flash Drive USB Device
ID du disque : 1A244A30
Type : USB
État : En ligne
Chemin : 0
Cible : 0
ID LUN : 0
Chemin d’accès de l’emplacement : UNAVAILABLE
État en lecture seule actuel : Non
Lecture seule : Non
Disque de démarrage : Non
Disque de fichiers d’échange : Non
Disque de fichiers de mise en veille prolongée : Non
Disque de fichiers de vidage sur incident : Non
Disque en cluster : Non
N° volume Ltr Nom Fs Type Taille Statut Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 3 D Amovible 0 o Inutilis.
Peut-être faudrait-il mettre le disk offline pour ne pas avoir l'erreur mais pas possible sur une clef usb
offline disk
Erreur du service de disque virtuel :
L’opération n’est pas prise en charge sur un média amovible.
8 Type convert mbr into the elevated terminal, and press Enter.
9 Type create partition primary size=1024 into the elevated terminal, and press Enter.
10 Type create partition primary into the elevated terminal, and press Enter.
comme après la création la partition 2 est déjà sélectionnée je la formate directement donc passer au point 15 :)
11 Type select partition 1 into the elevated terminal, and press Enter.
12 Type format fs=fat32 quick into the elevated terminal, and press Enter.
13 Type assign letter=X into the elevated terminal, and press Enter.
14 Type active into the elevated terminal and press Enter.
15 Type select partition 2 into the elevated terminal, and press Enter.
16 Type format fs=ntfs quick into the elevated terminal, and press Enter.
17 Type assign letter=Y into the elevated terminal, and press Enter.
18 You can now close the elevated Windows terminal.
19 Open File Explorer (Win+E) to This PC. You will see the USB has two partitions. Partition "X" with FAT32 file system, and partition "Y" with NTFS file system. (see screenshot below)
20 Mount the ISO file from step 1.
21 Perform the following steps to copy the mounted ISO contents to the USB X: (FAT32) partition:
- Click/tap on the mounted ISO in the navigation pane of File Explorer to open it.
- Select everything except the sources folder in the mounted ISO.
- Right click or press and hold on the selected files.
- Click/tap on Show more options (Shift+F10).
22 Click/tap on Send to, and click/tap on the USB Drive (X: ).
23 Perform the following steps to copy the "sources" folder from the mounted ISO to the USB Y: (NTFS) partition:
- Click/tap on the mounted ISO in the navigation pane of File Explorer to open it.
- Select only the sources folder in the mounted ISO.
- Right click or press and hold on the selected sources folder.
- Click/tap on Show more options (Shift+F10).
24 Click/tap on Send to, and click/tap on the USB Drive (Y: ).
It may take a while to finish copying the sources folder to the USB Y: (NTFS) partition.
25 Open the USB X: (FAT32) partition, and create a new folder (Ctrl+Shift+N) named sources.
26 Open the Y:\sources folder from the USB Y: (NTFS) partition, and Cut (Win+X) the boot.wim file.
28 The Windows 11 bootable USB installation media is now ready.
29 You can unmount the ISO file.
30 You can now close all File Explorer windows.
dimanche 22 janvier 2023
mount veracrypt volume with cryptsetup linux
Mount / Umount volume veracrypt avec cryptsetup
sudo cryptsetup --veracrypt open --type tcrypt '/media/moi/DT16G/container' veracrypt1
sudo mount /dev/mapper/veracrypt1 /media/veracrypt1/
sudo umount /media/veracrypt1
sudo cryptsetup --veracrypt close --type tcrypt veracrypt1
Avec veracrypt en cli
veracrypt '/media/moi/DT16G/container' /media/veracrypt1/
veracrypt -d veracrypt1
Veracrypt autoumount bat file
Installer veracrypt portable sur la clef usb
mount.bat
set drive=%cd=,~3%
%drive%VeraCrypt\VeraCrypt-x64.exe /q /e /m rm /m label=CryptVol /l M /v "%drive%container.vc"
exit
unmount.bat
set drive=%cd=,~3%
%drive%VeraCrypt\VeraCrypt-x64.exe /d M /f /q
exit
From https://veracrypt.eu/en/Command%20Line%20Usage.html
Command Line Usage
Note that this section applies to the Windows version of VeraCrypt. For information on command line usage applying to the Linux and Mac OS X versions, please run: veracrypt –h
| /help or /? | Display command line help. |
| /truecrypt or /tc | Activate TrueCrypt compatibility mode which enables mounting volumes created with TrueCrypt 6.x and 7.x series. |
| /hash | It must be followed by a parameter indicating the PRF hash algorithm to use when mounting the volume. Possible values for /hash parameter are: sha256, sha-256, sha512, sha-512, whirlpool, ripemd160 and ripemd-160. When /hash is omitted, VeraCrypt will try all possible PRF algorithms thus lengthening the mount operation time. |
| /volume or /v |
It must be followed by a parameter indicating the file and path name
of a VeraCrypt volume to mount (do not use when dismounting) or the
Volume ID of the disk/partition to mount. |
| /letter or /l | It must be followed by a parameter indicating the driver letter to mount the volume as. When /l is omitted and when /a is used, the first free drive letter is used. |
| /explore or /e | Open an Explorer window after a volume has been mounted. |
| /beep or /b | Beep after a volume has been successfully mounted or dismounted. |
| /auto or /a | If no parameter is specified, automatically mount the volume. If devices is specified as the parameter (e.g., /a devices), auto-mount all currently accessible device/partition-hosted VeraCrypt volumes. If favorites is specified as the parameter, auto-mount favorite volumes. Note that /auto is implicit if /quit and /volume are specified. If you need to prevent the application window from appearing, use /quit. |
| /dismount or /d | Dismount volume specified by drive letter (e.g., /d x). When no drive letter is specified, dismounts all currently mounted VeraCrypt volumes. |
| /force or /f | Forces dismount (if the volume to be dismounted contains files being used by the system or an application) and forces mounting in shared mode (i.e., without exclusive access). |
| /keyfile or /k | It must be followed by a parameter specifying a keyfile or a keyfile search path. For multiple keyfiles, specify e.g.: /k c:\keyfile1.dat /k d:\KeyfileFolder /k c:\kf2 To specify a keyfile stored on a security token or smart card, use the following syntax: token://slot/SLOT_NUMBER/file/FILE_NAME |
| /tryemptypass | ONLY when default keyfile configured or when a keyfile is specified in the command line. If it is followed by y or yes or if no parameter is specified: try to mount using an empty password and the keyfile before displaying password prompt. if it is followed by n or no: don't try to mount using an empty password and the keyfile, and display password prompt right away. |
| /nowaitdlg | If it is followed by y or yes or if no parameter is specified: don’t display the waiting dialog while performing operations like mounting volumes. If it is followed by n or no: force the display waiting dialog is displayed while performing operations. |
| /secureDesktop | If it is followed by y or yes or
if no parameter is specified: display password dialog and token PIN
dialog in a dedicated secure desktop to protect against certain types of
attacks. If it is followed by n or no: the password dialog and token PIN dialog are displayed in the normal desktop. |
| /tokenlib | It must be followed by a parameter indicating the PKCS #11 library to use for security tokens and smart cards. (e.g.: /tokenlib c:\pkcs11lib.dll) |
| /tokenpin | It must be followed by a parameter indicating the PIN to use in order to authenticate to the security token or smart card (e.g.: /tokenpin 0000). Warning: This method of entering a smart card PIN may be insecure, for example, when an unencrypted command prompt history log is being saved to unencrypted disk. |
| /cache or /c | If it is followed by y or yes or if no parameter is specified: enable password cache;
If it is followed by p or pim: enable both password and PIM cache (e.g., /c p). If it is followed by n or no: disable password cache (e.g., /c n). If it is followed by f or favorites: temporary cache password when mounting multiple favorites (e.g., /c f). Note that turning the password cache off will not clear it (use /w to clear the password cache). |
| /history or /h | If it is followed by y or no parameter: enables saving history of mounted volumes; if it is followed by n: disables saving history of mounted volumes (e.g., /h n). |
| /wipecache or /w | Wipes any passwords cached in the driver memory. |
| /password or /p | It must be followed by a parameter indicating the volume password. If the password contains spaces, it must be enclosed in quotation marks (e.g., /p ”My Password”). Use /p ”” to specify an empty password. Warning: This method of entering a volume password may be insecure, for example, when an unencrypted command prompt history log is being saved to unencrypted disk. |
| /pim | It must be followed by a positive integer indicating the PIM (Personal Iterations Multiplier) to use for the volume. |
| /quit or /q | Automatically perform requested actions and exit (main VeraCrypt window will not be displayed). If preferences is specified as the parameter (e.g., /q preferences), then program settings are loaded/saved and they override settings specified on the command line. /q background launches the VeraCrypt Background Task (tray icon) unless it is disabled in the Preferences. |
| /silent or /s | If /q is specified, suppresses interaction with the user (prompts, error messages, warnings, etc.). If /q is not specified, this option has no effect. |
| /mountoption or /m |
It must be followed by a parameter which can have one of the values indicated below. ro or readonly: Mount volume as read-only. rm or removable: Mount volume as removable medium (see section Volume Mounted as Removable Medium). ts or timestamp: Do not preserve container modification timestamp. sm or system: Without pre-boot authentication, mount a partition that is within the key scope of system encryption (for example, a partition located on the encrypted system drive of another operating system that is not running). Useful e.g. for backup or repair operations. Note: If you supply a password as a parameter of /p, make sure that the password has been typed using the standard US keyboard layout (in contrast, the GUI ensures this automatically). This is required due to the fact that the password needs to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available. bk or headerbak: Mount volume using embedded backup header. Note: All volumes created by VeraCrypt contain an embedded backup header (located at the end of the volume). recovery: Do not verify any checksums stored in the volume header. This option should be used only when the volume header is damaged and the volume cannot be mounted even with the mount option headerbak. Example: /m ro label=LabelValue: Use the given string value LabelValue as a label of the mounted volume in Windows Explorer. The maximum length for LabelValue is 32 characters for NTFS volumes and 11 characters for FAT volumes. For example, /m label=MyDrive will set the label of the drive in Explorer to MyDrive. noattach: Only create virtual device without actually attaching the mounted volume to the selected drive letter. Please note that this switch may be present several times in the command line in order to specify multiple mount options (e.g.: /m rm /m ts) |
| /DisableDeviceUpdate | Disables periodic internel check on devices connected to the system that is used for handling favorites identified with VolumeID and replace it with on-demande checks. |
| /protectMemory | Activates a mechanism that protects VeraCrypt process memory from being accessed by other non-admin processes. |
| /signalExit | It must be followed by a parameter specifying the name of the signal to send to unblock a waiting WAITFOR.EXE command when VeraCrypt exists. The name of signal must be the same as the one specified to WAITFOR.EXE command (e.g."veracrypt.exe /q /v test.hc /l Z /signal SigName" followed by "waitfor.exe SigName" This switch is ignored if /q is not specified |
VeraCrypt Format.exe (VeraCrypt Volume Creation Wizard):
| /create | Create a container based volume in command line mode. It must be followed by the file name of the container to be created. |
| /size |
(Only with /create)
|
| /password | (Only with /create) It must be followed by a parameter indicating the password of the container that will be created. |
| /keyfile or /k | (Only with /create) It must be followed by a parameter specifying a keyfile or a keyfile search path. For multiple keyfiles, specify e.g.: /k c:\keyfile1.dat /k d:\KeyfileFolder /k c:\kf2 To specify a keyfile stored on a security token or smart card, use the following syntax: token://slot/SLOT_NUMBER/file/FILE_NAME |
| /tokenlib | (Only with /create) It must be followed by a parameter indicating the PKCS #11 library to use for security tokens and smart cards. (e.g.: /tokenlib c:\pkcs11lib.dll) |
| /tokenpin | (Only with /create) It must be followed by a parameter indicating the PIN to use in order to authenticate to the security token or smart card (e.g.: /tokenpin 0000). Warning: This method of entering a smart card PIN may be insecure, for example, when an unencrypted command prompt history log is being saved to unencrypted disk. |
| /hash | (Only with /create) It must be followed by a parameter indicating the PRF hash algorithm to use when creating the volume. It has the same syntax as VeraCrypt.exe. |
| /encryption | (Only with /create) It must be followed by a parameter indicating the encryption algorithm to use. The default is AES if this switch is not specified. The parameter can have the following values (case insensitive):
|
| /filesystem | (Only with /create) It must be followed by a parameter indicating the file system to use for the volume. The parameter can have the following values:
|
| /dynamic | (Only with /create) It has no parameters and it indicates that the volume will be created as a dynamic volume. |
| /force | (Only with /create) It has no parameters and it indicates that overwrite will be forced without requiring user confirmation. |
| /silent | (Only with /create) It has no parameters and it indicates that no message box or dialog will be displayed to the user. If there is any error, the operation will fail silently. |
| /noisocheck or /n | Do not verify that VeraCrypt Rescue Disks are correctly burned. WARNING: Never attempt to use this option to facilitate the reuse of a previously created VeraCrypt Rescue Disk. Note that every time you encrypt a system partition/drive, you must create a new VeraCrypt Rescue Disk even if you use the same password. A previously created VeraCrypt Rescue Disk cannot be reused as it was created for a different master key. |
| /nosizecheck | Don't check that the given size of the file container is smaller than the available disk free. This applies to both UI and command line. |
| /quick | Perform quick formatting of volumes instead of full formatting. This applies to both UI and command line. |
| /FastCreateFile | Use a faster but potentially insecure way to create file containers. This applies to both UI and command line. |
| /protectMemory | Activates a mechanism that protects VeraCrypt Format process memory from being accessed by other non-admin processes. |
| /secureDesktop | If it is followed by y or yes or
if no parameter is specified: display password dialog and token PIN
dialog in a dedicated secure desktop to protect against certain types of
attacks. If it is followed by n or no: the password dialog and token PIN dialog are displayed in the normal desktop. |
Syntax
VeraCrypt.exe [/tc] [/hash {sha256|sha-256|sha512|sha-512|whirlpool |ripemd160|ripemd-160}][/a [devices|favorites]] [/b] [/c [y|n|f]] [/d [drive letter]] [/e] [/f] [/h [y|n]] [/k keyfile or search path] [tryemptypass [y|n]] [/l drive letter] [/m {bk|rm|recovery|ro|sm|ts|noattach}] [/p password] [/pim pimvalue] [/q [background|preferences]] [/s] [/tokenlib path] [/v volume] [/w]
"VeraCrypt Format.exe" [/n] [/create] [/size number[{K|M|G|T}]] [/p password] [/encryption {AES | Serpent | Twofish | Camellia | Kuznyechik | AES(Twofish) | AES(Twofish(Serpent)) | Serpent(AES) | Serpent(Twofish(AES)) | Twofish(Serpent) | Camellia(Kuznyechik) | Kuznyechik(Twofish) | Camellia(Serpent) | Kuznyechik(AES) | Kuznyechik(Serpent(Camellia))}] [/hash {sha256|sha-256|sha512|sha-512|whirlpool|ripemd160|ripemd-160}] [/filesystem {None|FAT|NTFS|ExFAT|ReFS}] [/dynamic] [/force] [/silent] [/noisocheck] [FastCreateFile] [/quick]
Note that the order in which options are specified does not matter.
Examples
Mount the volume d:\myvolume as the first free drive letter, using the password prompt (the main program window will not be displayed):
veracrypt /q /v d:\myvolume
Dismount a volume mounted as the drive letter X (the main program window will not be displayed):
veracrypt /q /d x
Mount a volume called myvolume.tc using the password MyPassword, as the drive letter X. VeraCrypt will open an explorer window and beep; mounting will be automatic:
veracrypt /v myvolume.tc /l x /a /p MyPassword /e /b
Create a 10 MB file container using the password test and formatted using FAT:
"C:\Program Files\VeraCrypt\VeraCrypt Format.exe" /create
c:\Data\test.hc /password test /hash sha512 /encryption serpent
/filesystem FAT /size 10M /force
vendredi 26 mars 2021
simple bash CLI commands cpu info, afficher cpu frequency, stress cpu test, scaling governor
Pour visualiser toutes les infos sur tes cpu :
cat /proc/cpuinfo
Pour afficher les fréquences de fonctionnement des cpu toutes les 0,5s :
watch -n 0,5 'cat /proc/cpuinfo | grep "MHz"'
Ctrl - c pour stopper
Pour changer le governor (en admettant que ce soit utile...)
sudo -sE pour devenir root
Passer en powersave
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "powersave" > $file; done
en performance
for file in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do echo "performance" > $file; done
Pour afficher l'état actuel
cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Pour stresser un peu les cores du cpu voilà qui peut faire l'affaire :
D'abord créer un fichier binaire de données aléatoires, rien de plus simple :
dd if=/dev/urandom of=512.bin bs=32M count=16 iflag=fullblock
pour un fichier de 512Mo nommé (astucieusement) 512.bin
Ajuster bs ou count pour changer la taille selon les besoins
Lancer le stress test avec plusieurs instances de bzip2 depuis le répertoire où se trouve le fichier bin avec la commande (bash) suivante :
for instance in {1..4}; do coproc bzip2 -k 512.bin -c > /dev/null ; done
ajuster le nombre d'instance de bzip2 en changeant la valeur dans la liste, ici 4
Pour voir les jobs... utiliser la commande jobs ;)
Pour killer tous les jobs :
kill %{1..4} ajuster selon le nombre d'instances
ou
kill %n pour killer seulement le job n
jeudi 11 février 2021
Rescale pictures with ffmpeg
FFmpeg has got a very powerful scale filter, which can be used to accomplish various tasks. Some of them are listed here. More can be found in the official documentation. In all the examples, the starting image (input.jpg) will be this one (535x346 pixels):
If you need to simply resize your video to a specific size (e.g 320x240), you can use the scale filter in its most basic form:
ffmpeg -i input.avi -vf scale=320:240 output.avi
Same works for images too:
ffmpeg -i input.jpg -vf scale=320:240 output_320x240.png
The resulting image will look like this:
As you can see, the aspect ratio is not the same as in the original image, so the image appears stretched. If we'd like to keep the aspect ratio, we need to specify only one component, either width or height, and set the other component to -1. For example, this command line:
ffmpeg -i input.jpg -vf scale=320:-1 output_320.png
will set the width of the output image to 320 pixels and will calculate the height of the output image according to the aspect ratio of the input image. The resulting image will have a dimension of 320x207 pixels.
There are also some useful constants which can be used instead of numbers, to specify width and height of the output image. For example, if you want to stretch the image in such a way to only double the width of the input image, you can use something like this (iw = input width constant, ih = input height constant):
ffmpeg -i input.jpg -vf scale=iw*2:ih input_double_width.png
The output image will look like this:
If you want to half the size of the picture, just multiply by .5
ffmpeg -i input.jpg -vf scale=iw*.5:ih*.5 input_half_size.png
Sometimes there is a need to scale the input image in such way it fits into a specified rectangle, i.e. if you have a placeholder (empty rectangle) in which you want to scale any given image. This is a little bit tricky, since you need to check the original aspect ratio, in order to decide which component to specify and to set the other component to -1 (to keep the aspect ratio). For example, if we would like to scale our input image into a rectangle with dimensions of 320x240, we could use something like this:
ffmpeg -i input.jpg -vf scale="'if(gt(a,4/3),320,-1)':'if(gt(a,4/3),-1,240)'" output_320x240_boxed.png
The output image will look like this:
The area below the image is shaded with boxes to show there was some additional space left in the box, due to the original image not having the same aspect ratio as the box, in which the image was supposed to fit.
Of course, this approach is only used when your input image is not known in advance, because if it was known, you would easily figure out if you need to use either:
-vf scale=320:-1
or
-vf scale=-1:240
vendredi 8 janvier 2016
UBUNTU 14.04 - network manager cli command nmcli
Pour gérer le network manager et lister les infos comme le DNS
nmcli dev list
nmcli dev list iface eth1|grep IP4
jeudi 7 janvier 2016
ubuntu wifi settings by cli iwconfig command
iwconfig eth1 mode managed key restricted motdepasseduwifi
iwconfig eth1 essid MyWifi
ifconfig eth1 up
dhclient eth1
mardi 15 décembre 2015
Verify & Repair Permissions in OS X El Capitan via command line
To verify
sudo /usr/libexec/repair_packages --verify --standard-pkgs /
To repair
sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume /