


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Notes regarding Linux Command for Revision
Typology: Study notes
1 / 34
This page cannot be seen from the preview
Don't miss anything!
Syntax pwd [-LP]
Options -P : The pathname printed will not contain symbolic links. -L : The pathname printed may contain symbolic links
Syntax ls [ Options ]... [ File ]...
Key Sort entries alphabetically if none of -cftuSUX nor --sort.
-a, --all Do not hide entries starting with.
-A, --almost-all Do not list implied. and ..
-c Sort by change time; with -l: show ctime
-d, --directory List directory entries instead of contents
-f Do not sort, enable -aU, disable -lst
-i, --inode Print index number of each file
-k, --kilobytes Like --block-size=
-l Use a long listing format
-L, --dereference List entries pointed to by symbolic links
characters specially)
-r, --reverse Reverse order while sorting
-R, --recursive List subdirectories recursively
-s, --size Print size of each file, in blocks
-t sort by modification time
-u sort by last access time; with -l: show atime
-U do not sort; list entries in directory order
-v sort by version
-1 list one file per line
--help display help and exit
--version output version information and exit
$ ls ~
$ ls -al
total 109 drwxr-xr-x 18 root root 4096 Jun 9 21:12 ./ drwxr-xr-x 18 root root 4096 Jun 9 21:12 ../ drwxr-xr-x 2 root root 4096 Jun 9 21:14 bin/ drwxr-xr-x 3 root root 1024 Jun 9 20:32 boot/ drwxr-xr-x 6 root root 36864 Jul 12 10:26 dev/ drwxr-xr-x 34 root root 4096 Jul 12 10:25 etc/ ^ the first column is the file type d = directory f = file
*$ ls -d /
**$ ls ***
Syntax cd [ Options ] [D irectory ]
-m Print the current user id, name and domain (Same as `who am i')
-q --count Print only the login names and the number of users logged on. Overrides all other options.
-i The who command differs from whoami in that it provides a list of all users currently logged into the system as well as additional information about each of those users (including login times and terminal numbers). It also differs in that, in the event of a change in ownership of a login session through the use of the su command, it reports the original owner of the session, whereas whoami provides the user name of the effective (i.e., current) owner of the session.
who' uses that instead of
/var/run/utmp' as the name of theam i', as in
who am i'.Syntax whoami [ options ]
Options --help Display Help --version Display program version info
Syntax which [ options ] [--] program_name [...]
Options --all, -a Print all matching executables in PATH, not just the first.
--read-alias, -i Read aliases from stdin, reporting matching ones on stdout. This is useful in combination with using an alias for which itself. For example alias which='alias | which -i'.
Syntax cp [ options ]... Source Dest cp [ options ]... Source ... Directory
Key
-a, --archive same as -dpR
-b, --backup make backup before removal
-d, --no-dereference preserve links
-f, --force remove existing destinations, never prompt
-i, --interactive prompt before overwrite
-l, --link link files instead of copying
-p, --preserve preserve file attributes if possible
-P, --parents append source path to DIRECTORY
-r copy recursively, non-directories as files
--interactive Prompt whether to overwrite each existing destination file, regardless of its permissions. If the response does not begin with y' or
Y', the file is skipped.
--help display help and exit --version output version information and exit
Examples
Rename the file apple as orange.doc: mv apple orange.doc
Move orange.doc to the Documents folder: mv orange.doc ~/Documents/orange.doc
Rename a bunch of file extensions e.g. change *.txt into *.htm for f in *.txt; do mv ./"$f" "${f%txt}htm"; done
--force' option is not given,
mv' prompts the user for whether to replace the file. (You mightSyntax rm [ options ]... file ...
Options -d, --directory unlink directory, even if non-empty (super-user only)
-f, --force ignore nonexistent files, never prompt
-i, --interactive prompt before any removal
-r, -R, --recursive remove the contents of directories recursively
-v, --verbose explain what is being done
--help display this help and exit
--version output version information and exit
mkdir [ Options ] folder ...
mkdir " Name with spaces "
-m, --mode= MODE set permission mode (as in chmod), not rwxrwxrwx - umask -p, --parents no error if existing, make parent directories as needed --verbose print a message for each created directory
hostname [ name ]
Syntax cal [-mjy] [[ month ] year ]
Options:
-m Display monday as the first day of the week.
-j Display julian dates (days one-based, numbered from January 1).
-y Display a calendar for the current year.
A single parameter specifies the 4 digit year (1 - 9999) to be displayed.
Two parameters denote the Month (1 - 12) and Year (1 - 9999).
If arguments are not specified, the current month is displayed.
A year starts on 01 Jan.
Syntax cat [ Options ] [ File ]...
Concatenate FILE (s), or standard input, to standard output.
-A, --show-all equivalent to -vET
-n, --number number all output lines
--help display this help and exit
--version output version information and exit
With no FILE , or when FILE is -, read standard input.
cat File3.txt
mount [-fnrsvw] [-o options [,...]] device | dir
-a Mount all filesystems (of the given types) mentioned in fstab.
-h Print a help message.
-V Output version.
Syntax echo [ options ]... [ string ]...
Options
-n Do not output the trailing newline.
Disable the interpretation of the following backslash-escaped characters
-e Enable interpretation of the following backslash-escaped characters in each STRING:
\a alert (bell)
\b backspace
\c suppress trailing newline
\e escape
\f form feed
\n new line
\r carriage return
\t horizontal tab
\v vertical tab
\ backslash
the character whose ASCII code is NNN (octal); if NNN is not a valid octal number, it is printed literally.
\x nnn the character whose ASCII code is the hexadecimal value nnn (one to three digits)
Syntax wc [ options ]... [ file ]...
Options
-c --bytes --chars Print only the byte counts.
-w --words Print only the word counts.
-l --lines Print only the newline counts.
-L --max-line-length Print only the length of the longest line per file, and if there is more than one file it prints the maximum (not the sum) of those lengths.
ibm' Convert ASCII to alternate EBCDIC.
block' For each line in the input, output cbs' bytes, replacing the input newline with a space and padding with spaces as necessary.
unblock' Replace trailing spaces in each cbs'-sized input block with a newline.
lcase' Change uppercase letters to lowercase. ucase' Change lowercase letters to uppercase.
swab' Swap every pair of input bytes. GNU dd', unlike others, works when an odd number of bytes are read--the last byte is simply copied (since there is nothing to swap it with).
noerror' Continue after read errors. notrunc' Do not truncate the output file.
sync' Pad every input block to size of `ibs' with trailing zero bytes.
c'=1,
w'=2, xM'=M, or any of the standard block size suffixes like
k'=1024.Syntax test expr [ expr
Options
! expr True if expr is false. ( expr )
Returns the value of expr. This may be used to override the normal precedence of operators. expr1 -a expr True if both expr1 and expr2 are true. expr1 -o expr True if either expr1 or expr2 is true.
-a' and
-o' operators are considered binary operators in thisTrue if file has its set-user-id bit set.
`-w file ' True if file is writable.
`-x file ' True if file is executable.
` file 1 -ef file 2' True if file 1 and file 2 have the same device and inode numbers, i.e., if they are hard links to each other.
` file 1 -nt file 2' True if file 1 is newer than file 2.
` file 1 -ot file 2' True if file 1 is older than file 2.
`-z String ' True if the length of String is zero.
-n _String_ '
String ' True if the length of String is nonzero.
` String 1 = String 2' True if the strings are equal.
` String 1 != String 2' True if the strings are not equal.
ARG1 -eq ARG2'
ARG1 -ne ARG2' ARG1 -lt ARG2'
ARG1 -le ARG2' ARG1 -gt ARG2'
ARG1 -ge ARG2' These arithmetic binary operators return true if ARG1 is equal, not-equal, less-than, less-than-or-equal, greater-than, or greater-than-or-equal than ARG2, respectively.
For example:
test -1 -gt -2 && echo yes => yes test -l abc -gt 1 && echo yes => yes test 0x100 -eq 1 error--> test: integer expression expected before -eq
$ ls -al total 67
drwxr-xr-x 18 root root 4096 Jun 9 21:12 ./ drwxr-xr-x 18 root root 4096 Jun 9 21:12 ../ -rw-rw-rw- 1 simon users 4096 Jun 9 07:30 london -rwsrwsrwx 1 simon users 4096 Jun 9 07:32 aberdeen -rw------- 1 simon users 4096 Jun 9 07:29 bristol -rw-r--r-- 1 simon users 4096 Jun 9 07:29 bath $
if [ "$LOGNAME" = "scott" ] then echo "Logged in as Scott" else echo "incorrect user" fi
Syntax chmod [ Options ]... Mode [, Mode ]... file ...
chmod [ Options ]... Numeric_Mode file ...
chmod [ Options ]... --reference= RFile file ...
Options -f, --silent, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed