0% found this document useful (0 votes)
106 views1 page

Linux Command Line Cheat Sheet

This cheat sheet provides a summary of common Linux commands for processes, storage, file systems, users, and scripting. It includes commands for viewing processes like ps and pstree, partitioning and creating file systems like fdisk, mkfs, and mount, managing files and directories like cp, mv, rm, and du, interacting with processes using kill and jobs, and creating/modifying users with useradd, usermod, and userdel. It also lists bash operators and control structures for scripting like if/else, for loops, and while loops.

Uploaded by

Roxana Vlad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views1 page

Linux Command Line Cheat Sheet

This cheat sheet provides a summary of common Linux commands for processes, storage, file systems, users, and scripting. It includes commands for viewing processes like ps and pstree, partitioning and creating file systems like fdisk, mkfs, and mount, managing files and directories like cp, mv, rm, and du, interacting with processes using kill and jobs, and creating/modifying users with useradd, usermod, and userdel. It also lists bash operators and control structures for scripting like if/else, for loops, and while loops.

Uploaded by

Roxana Vlad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Cheat Sheet

Processes  tail [-n N] file – display last N


lines of file
View  cut –d delimiters –f fields – select
 ps [-e] [-f] - show processes “colums” from an input text
information  tr char1 char2 – change char1 to
Storage E.g.: ps –ef ; ps aux; ps –u root –f char2
 pstree [-a] [-p] [pid]  tr [-s] [-d] char – squeeze or
Partitioning delete character
 fdisk /dev/sdb –partitioning utility Interact  wc [-l] [-w] [-c] – count
 mkswap device_file  kill –l – show available signals lines/words/characters
- swapon device_file
 kill [–s signalName] pid – send
- swapoff [device_file] Bash operators
signal signalName to process pid
 kill [–signalNumber] pid
File systems
 kill all [-s signal] name – send  Chaining:
 mkfs –t fs_type device_file
signal to all process name - Sequence: ;
E.g.: mkfs –t ext4 /dev/sdb2 - Parallel execution: &
 jobs – show jobs
 mount –t fs_type [-o options] - Conditional execution: &&,||
device_file mount_point  fg [job_number] – bring job
job_number to foreground  Pipelines: |, |&
E.g.: mount –t ext4 /dev/sdb3 /mnt/data
 bg [job_number] – send job  Input/Output redirection
 umount device_file / umount - Redirecting input: <,<<,<<<
job_number to background
mount_point - Redirecting output:
Users >,>>,2>,2>>,&>,&>>
File and directory operations
 ls file – show information about Scripting
file or folder Create
Note: By default, a script returns 0
 cp [options] source destination  useradd –d HOME_DIR –m –s SHELL –g
E.g.: cp file1 file2 ; cp –r dir1 dir2 GROUP USERNAME
 if condition1;
 mv source destination  adduser username then
 rm [-r] file – use –r option to Note: adduser only valid in Debian commands
delete non empty folders [ elif condition2;
E.g.: rm file1 ; rm –r dir1 Mod then
 cd path – change working directory  usermod (similar arguments as commands]
to path useradd) [ else
 mkdir dir – create directory E.g.: usermod –d /localhome/sqa sqa commands]
fi
 rmdir dir – remove directory (only
if directory is empty) Delete
 userdel username E.g: if [ $a –lt 10 ] – value of a is less
 df – “disk free” show available than 10
space  deluser username
if [ $str1 = $str2 ] – test if two
 du – “disk usage” show used space strings are equal
Switching users: su [-] username
File security  for member in list;
Using the shell do
 chown user:group file – change file commands
owner  cat [-n] file1 file2 … - concatenate done
 chmod permissions file – change file multiple files
permissions  tac [-n] file1 file2 …  while condition;
E.g.: chmod 777 file.txt; chmod u=rwx,g=rx,o=rx  sort [-u] [-r] [-n] [file] do
file.txt ; chmod +x file.txt  head [-n N] file – display first N commands
lines of file done

You might also like