Basic Linux Commands
• File Handling
• Text Processing
• System Administration
• Process Management
• Archival
• Network
• File Systems
• Advanced Commands
~$ man <command> shows all information about the command
~$ <command> --help
Shows the available options for that command
File handling commands
~$ mkdir – make directories
Usage: mkdir [option] directory name...
eg. mkdir bigdata
~$ls – list directory contents
Usage: ls [option]... [File]...
eg. ls, ls l,
ls bigdata
~$cd – changes directories
Usage: cd [directory]
eg. cd bigdata
~$ pwd-print name of current working directory
Usage: pwd
~$vim – Vi Improved, a programmers text editor
Usage: vim [option] [file]... eg. vim [Link]
~$cp – copy files and directories
Usage: cp [option] source_path<space>dest_path
eg. cp [Link] sample_copy.txt
cp sample_copy.txt target_dir
~$mv – move (rename) files
Usage: mv [option] source_path<space>dest_path
eg. mv [Link] target_dir
mv [Link] [Link]
~$ rm remove files or directories
Usage: rm [option]... file...
eg. rm [Link] , rm rf some_dir
~$ find – search for files in a directory hierarchy
Usage: find [option] [path] [pattern]
eg. find [Link], find name [Link]
~$ history – prints recently used commands
Usage: history.
ls *.txt – prints all text files
Text Processing
~$cat – concatenate files and print on the standard output
Usage: cat [option] [file]...
eg. cat [Link] [Link]
cat n [Link]
~$echo – display a line of text
Usage: echo [option] [string] ...
eg. echo I love India
echo $HOME
~$grep- print lines matching a pattern
Usage: grep [option] pattern [file]...
eg. grep i apple [Link]
~$ wc print the number of newlines, words, and bytes in files
Usage: wc [option]... [file]... eg. wc [Link]
wc l [Link]
~$ sort – sort lines of text files
Usage: sort [option]... [file]...
eg. sort [Link] [or ]sort r [Link]
Linux File Permissions
• 3 types of file permissions – read, write, execute
• 10 bit format from 'ls l' command
1 234 5 6 7 8 9 10
file type owner group others
eg. drwxrwr means owner has all three permissions, group has read and
write, others have only read
permission
• read permission – 4, write – 2, execute 1
eg. rwxrwr=764
673 = rwrwxwx
System Administration
~$chmod – change file access permissions
Usage: chmod<space>[option] [mode]<space> [file]
eg. chmod 744 [Link]
~$chown – change file owner and group
Usage: chown [option]... owner[:[group]] file...
eg. chown owener_name [Link]
~$ su – change user ID or become superuser
Usage: su [option] [login]
eg. su owener_name, su
~$passwd – update a user’s authentication tokens(s)
Usage: passwd [option]
eg. passwd
~$who – show who is logged on
Usage: who [option]
eg. who , who b, who q
~$ ps – report a snapshot of the current processes
Usage: ps [option]
eg. ps, ps el
~$ kill – to kill a process(using signal mechanism)
Usage: kill [option] pid
eg. kill 9 2275
Process Management
~$tar – to archive a file
Usage: tar [option]<space>source<space>destination
eg. tar cvf /home/[Link] /home/original
tar xvf /home/[Link]
~$zip – package and compress (archive) files
Usage: zip [option]<space> source<space>destination
eg. zip [Link] original
~$unzip – list, test and extract compressed files in a ZIP archive
Usage: unzip filename
eg. unzip [Link]
Network
~$ssh – SSH client (remote login program)
“ssh is a program for logging into a remote machine and for
executing commands on a remote machine”
Usage: ssh [options] [username]@hostname
eg. ssh guest@[Link]
~$scp – secure copy (remote file copy program)
“scp copies files between hosts on a network”
Usage: scp [options] [[user]@host1:file1] [[user]@host2:file2]
eg. scp [Link] guest@[Link]:~/Desktop/
File Systems
~$fdisk – partition manipulator
eg. sudo fdisk l
~$mount – mount a file system
Usage: mount t type device dir
eg. mount /dev/sda5 /media/target
~$umount – unmount file systems
Usage: umount [option] dir | device...
eg. umount /media/target
~$ du – estimate file space usage
Usage: du [option]... [file]...
eg. du
~$df – report filesystem disk space usage
Usage: df [option]... [file]...
eg. df
~$quota – display disk usage and limits
Usage: quota [option]
eg. quota v
Advanced Commands
~$ reboot – reboot the system
Usage: reboot [option]
eg. reboo
~$ poweroff – power off the system
Usage: poweroff [option]
eg. poweroff
Editor commands
~$kate – KDE Advanced Text Editor
Usage: kate [options][file(s)]
eg. kate [Link] [Link]
~$vim – Vi Improved, a programmers text editor
Usage: vim [option] [file]...
eg. vi hello.c
after completion of program press Esc :x to save file
~$gedit- A text Editor. Used to create and edit files.
Usage: gedit [option] [file]...
eg. gedit
~$bg – make a foreground process to run in background
Usage: type 'ctrl+z' and then 'bg <job id>'
~$ fg –to make background process as foreground process
Usage: fg [jobid]
~$ jobs – displays the names and ids of background jobs
Usage: jobs
~$sed stream
editor for filtering and transforming text
Usage: sed [option] [inputfile]...
eg. sed 's/love/hate/g' [Link]
~$ awk pattern scanning and processing language
eg. awk F:'{ print $1 }' sample_awk.txt
~$find search for files in a directory hierarchy
Usage: find [option] [path] [pattern]
eg. find name [Link]
~$locate – find or locate a file
Usage: locate [option]... file...
eg. locate [Link]