Linux Cheat sheet v1.1 +: add mode cat [options] file(s) 2 Process Commands wget [options] url 2019-08-28 - by A.Mahouachi -: remove mode options ps [options] options: =: exact mode -v: non ascii chars except tab and eol options: 1 File Commands r: read -b: run in background -T: show tabs -e: all processes -o file: print wget output in file ls [options] file w: write -t: equivalent to -vT x: execute files and search for dirs -f: full listing -o /dev/null: suppress wget output options -E: show eol end of line -H: show hierarchy X: search for dirs -q: be quiet -a: show hidden -e: equivalent to -vE -p pid: this process pid -d: debug s: setuid or setguid -A: equivalent to -vET -A: show hidden except . and .. t: sticky bit -C cmd: this command name cmd -O file: save response to file -h: human readable size -s: remove repeat empty lines -w: wide output -c: resume file download -i: inode info numeric mode -ww: to show long command lines -S: print server headers tail [options] file -l: long list format format: [0-7]1,4 -l: long listing, including wchan -T N: timeout after N seconds example: 755 options -o x,y,z: show columns x y z -m: output as csv –user=user: basic auth user -n: numeric uid and guid first digit: setuid(4), setguid(2) -f: show end of file live -o user,pid,cmd: show columns user, –password=pwd: basic auth password -r: sort in reverse order second digit: owner perms -35: show last 35 lines pid command –save-cookies file: save cookies to file -S: sort by file size third digit: group perms -q: be quiet -N: negation –load-cookies file: use file as cookies -t: sort by modification time fourth digit: others perms head [options] file -u user: processes owned by user –post-data=string tree [options] dir read: 4 options -u user -N: processes not owned by user –post-file=file options write: 2 –sort=x,y: x y are columns in ps output –no-check-certificate: ignore ssl certifi- execute: 1 -35: show first 35 lines –sort=user: sort by user cate -d: only directories -q: be quiet –sort=+time: sort by cpu time asc -f: show full paths find path [options] [tests] [actions] tac file(s) –sort=-time: sort by cpu time desc curl [options] url -P pattern: only matching pattern options: –sort=size: sort by memory size -I pattern: except matching pattern -mindepth x: ignore levels < x depth print files starting from last line –sort=vsize: sort by vm size options: -h: print sizes in human readable way -maxdepth y: ignore levels > y depth cut [options] file -H header: like -H "Host: st.com" -C: use colors tests: options top [options] options -u <user:password>: basic http auth -L x: max x level depth -name "xyz*": name like xyz* -d char: use char as delimiter -s: be silent -iname "xyz*": case insensitive -f 1,3,5: print fields 1, 3 and 5 -d x: refresh every x seconds -S: show errors if silent mode cp [options] source dest -type d: only directories -p pid1 -p pid2: only processes with -L: follow new location in case 301 options -type f: only files uniq [options] input output pid1 pid2 –data "field=value": x-www-form- -mtime 0: modified < 1 day options -c : show command lines urlencoded query -b: backup dest before overwrite -mtime -x: modified < x days interactive commands -r: recursive -c: prefix lines by occurrence –data-binary data: post data as is wi- -mtime +x: modified > x days -d: only print duplicate lines space: udpdate display thout encoding -f: force -mmin: like -mtime but in minutes n: change number of displayed proces- -l: link files instead of copy -u: only print unique lines –data-binary @filename: post filename -size +100M: size > 100MB ses content as is -P: dont follow sym links -size -100M: size < 100MB sort [options] file up and down: browse processes -i: interactive -X method: use PUT, GET, POST etc. (M for MB, k for KB, G for GB) options k: kill a process –request method: use PUT, GET, POST -u: copy only if source newer than dest -perm /o+w: writable by others o: change order -n: numeric sort etc. mv [options] source dest ! -perm /o+r : not readable by others -b: ignore blank lines T: sort by time options actions: -f: ignore case A: sort by age -print: print matching mail [options] to-address -b: backup dest before overwrite -r: reverse order P: sort by cpu -f: force -delete: rm matching files M: sort by memory options: -exec cmd ’{}’ ; : cmd on every match tar [options] file c: display/hide command line -i: interactive options -s subject: email with subject -u: move only if source newer than dest -exec cmd ’{}’ + : cmd once on all results m: display/hide memory -c address1,address2: cc copy -exec rm -rf ’’ : remove matching items -f file: archive file t: display/hide cpu -b address1,address2: bcc copy ln [options] file link -c: create -fprint /tmp/result: write matches to f: manage list of displayed columns mail -s ’hello there’ ’[email protected]’ < so- options -t: list /tmp/result up and down: move between columns mefile -s: sym link (hard by default) -x: extract d: display/hide the selected column -f: overwrite link if exists diff [options] files -C DIR: cd to DIR q: apply and quit the field mgmt 4 Terminal -b: backup old link before overwrite options -z: gzip screen rm [options] file -r: recursive -j: bzip2 (C- = Ctrl, M- = Alt) -w: ignore whitespaces pgrep [options] pattern C-c: halt current process options du [options] file options -B: ignore blank lines C-z: pause current process -f: force -q: only show file names options: -l : show pid and process name bg %1: resume it in background -i: interactive -x".sync*": exclude files with path like -c: a grand total -a : show pid and full command line fg %1: resume it in foreground rm – -foo if file name is -foo .sync* -h: human readable -n : if more than one show newest jobs: list background processes chmod [options] mode file(s) -L: dereference sym links -o : if more than one show oldest C-d: logout options grep [options] pattern files -P: no dereference of sym links -u uid : show only processes of uid C-r: search in history options -s: total for each argument -c : count results C-k: remove to end of current line -R: recursive -i: ignore case –exclude=pattern 3 Network & Remote C-y: paste removed text symbolic mode -P: pattern is a perl regex -max-depth=N: no deeper than N levels C-w: remove a word backward format: [ugoa][[+-=][perms]],... -m: stop after m matches ssh [options] user@host ["cmd1;cmd2"] M-d: remove a word forward example: u+x,o-wx,g-w -n: also show matching line number df [options] file options: C-u: remove current line u: owner -R: recurse directories options: -2: force protocol 2 C-a: beginning of current line g: group -c: only show matching lines count -h: human readable -o StrictHostKeyChecking=no: ignore C-e: end of current line o: others –exclude=glob : exclude these -i: list inodes info remote host key change C-x C-e: edit current line in $EDITOR a: all –include=glob : only consider these -P: no dereference of sym links -X: forward X11 display
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-