Linux Basic Commands

Published on Author bloggerfive

File Handling commands

mkdir – make directories

Usage: mkdir [OPTION] DIRECTORY…

Example : mkdir howwhywhat

ls – list directory contents

Usage: ls [OPTION]… [FILE]…

Example : ls, ls ­l, ls howwhywhat

  • cd – changes directories

Usage: cd [DIRECTORY]

Example : cd howwhywhat

  • pwd ­ print name of current working directory

Usage: pwd

  • vim – Vi Improved, a programmers text editor

Usage: vim [OPTION] [file]…

Example : vim file1.txt

  • cp – copy files and directories


Example : cp sample.txt sample_copy.txt

Example : cp sample_copy.txt target_dir

  • mv – move (rename) files


Example : mv source.txt target_dir

mv old.txt new.txt

  • rm ­ remove files or directories

Usage: rm [OPTION]… FILE…

Example : rm file1.txt , rm ­rf some_dir

  • find – search for files in a directory hierarchy

Usage: find [OPTION] [path] [pattern]

Example : find file1.txt, find ­name file1.txt

  • history – prints recently used commands

Usage: history


A Pattern is an expression that describes a set of strings which is used to give a concise description of a set, without having to list all elements.

Example : ab*cd matches anything that starts with ab and ends with cd etc.

ls *.txt – prints all text files

Text Processing

  • cat – concatenate files and print on the standard output

Usage: cat [OPTION] [FILE]…

Example : cat file1.txt file2.txt cat ­n file1.txt

echo – display a line of text

Usage: echo [OPTION] [string] …

Example : echo I love India echo $HOME

grep ­ print lines matching a pattern

Usage: grep [OPTION] PATTERN [FILE]…

Example : grep ­i apple sample.txt

wc ­ print the number of newlines, words, and bytes in files

Usage: wc [OPTION]… [FILE]…

Example : wc file1.txt wc ­L file1.txt

sort – sort lines of text files

Usage: sort [OPTION]… [FILE]…

Example : sort file1.txt sort ­r file1.txt

Linux File Permissions

  • 3 types of file permissions – read, write, execute
  • 10 bit format from ‘ls ­l’ command

1 2 3 4 5 6 7 8 9 10

file type owner group others

Example : drwxrw­r­­ means owner has all three permissions,

group has read and write, others have only read permission

• read permission – 4, write – 2, execute ­1

Example : rwxrw­r­­ = 764

673 = rw­rwx­wx

System Administration

chmod – change file access permissions

Usage: chmod [OPTION] [MODE] [FILE]

Example : chmod 744

chown – change file owner and group

Usage: chown [OPTION]… OWNER[:[GROUP]] FILE…

Example : chown remo myfile.txt

  • su – change user ID or become super­user

Usage: su [OPTION] [LOGIN]

Example : su remo, su

  • passwd – update a user’s authentication tokens(s)

Usage: passwd [OPTION]

Example : passwd

  • who – show who is logged on

Usage: who [OPTION]

Example : who , who ­b , who ­q

Process Management

  • ps – report a snapshot of the current processes

Usage: ps [OPTION]

Example : ps, ps ­el

  • kill – to kill a process(using signal mechanism)

Usage: kill [OPTION] pid

Example : kill ­9 2275

  • 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


tar – to archive a file


Example : tar ­cvf /home/archive.tar /home/original tar ­xvf /home/archive.tar

  • zip – package and compress (archive) files


Example : zip original

  • unzip – list, test and extract compressed files in a ZIP archive

Usage: unzip filename

Example : unzip


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] [user]@hostname Example : ssh ­X guest@

scp – secure copy (remote file copy program) “scp copies files between hosts on a network”

Usage: scp [options] [[user]@host1:file1] [[user]@host2:file2]

Example : scp file1.txt guest@

File Systems

  • fdisk – partition manipulator

Example : sudo fdisk ­l

  • mount – mount a file system

Usage: mount ­t type device dir

Example : mount /dev/sda5 /media/target

  • umount – unmount file systems

Usage: umount [OPTIONS] dir | device…

Example : umount /media/target

  • du – estimate file space usage

Usage: du [OPTION]… [FILE]…

Example : du

  • df – report filesystem disk space usage

Usage: df [OPTION]… [FILE]…

Example : df

  • quota – display disk usage and limits

Usage: quota [OPTION]

Example : quota ­v

Advanced Commands

reboot – reboot the system

Usage: reboot [OPTION]

Example : reboot

poweroff – power off the system

Usage: poweroff [OPTION]

Example : Poweroff

  • sed ­ stream editor for filtering and transforming text

Usage: sed [OPTION] [input­file]…

Example : sed ‘s/love/hate/g’ loveletter.txt

  • awk ­ pattern scanning and processing language

Example : awk ­F: ‘{ print $1 }’ sample_awk.txt

find ­ search for files in a directory hierarchy

Usage: find [OPTION] [path] [pattern]

Example : find ­name file1.txt

locate – find or locate a file

Usage: locate [OPTION]… FILE…

Example : locate file1.txt

Editor commands

kate – KDE Advanced Text Editor

Usage: kate [options][file(s)]

Example : kate file1.txt file2.txt

vim – Vi Improved, a programmers text editor Usage: vim [OPTION] [file]…

Example : vi hello.c

gedit ­ A text Editor. Used to create and edit files.

Usage: gedit [OPTION] [FILE]…

Example : gedit