0% found this document useful (0 votes)
23 views26 pages

Linux Basic Commands

The document provides an overview of basic Linux commands categorized into file handling, text processing, system administration, process management, archival, networking, file systems, and advanced commands. It includes usage examples for each command and highlights resources for learning commands, such as manual pages and books. Additionally, it discusses Linux file permissions and offers insights into process management and text editing tools.

Uploaded by

rakeshjadhav7625
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)
23 views26 pages

Linux Basic Commands

The document provides an overview of basic Linux commands categorized into file handling, text processing, system administration, process management, archival, networking, file systems, and advanced commands. It includes usage examples for each command and highlights resources for learning commands, such as manual pages and books. Additionally, it discusses Linux file permissions and offers insights into process management and text editing tools.

Uploaded by

rakeshjadhav7625
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/ 26

Linux

Basic Commands
Basic Linux Commands
• File Handling
• Text Processing
• System Administration
• Process Management
• Archival
• Network
• File Systems
• Advanced Commands
Sources to learn commands??


Primary – man(manual) pages.

man <command> ­ shows all information about the
command

<command> ­­help ­ shows the available options
for that command

Secondary – Books and Internet
File Handling commands
• mkdir – make directories
Usage: mkdir [OPTION] DIRECTORY...
eg. mkdir prabhat
• ls – list directory contents
Usage: ls [OPTION]... [FILE]...
eg. ls, ls ­l, ls prabhat
• cd – changes directories
Usage: cd [DIRECTORY]
eg. cd prabhat
File Handling(contd...)

• pwd ­ print name of current working directory


Usage: pwd

• vim – Vi Improved, a programmers text editor


Usage: vim [OPTION] [file]...
eg. vim [Link]
File Handling(contd...)

cp – copy files and directories
Usage: cp [OPTION]... SOURCE DEST
eg. cp [Link] sample_copy.txt
cp sample_copy.txt target_dir

mv – move (rename) files
Usage: mv [OPTION]... SOURCE DEST
eg. mv [Link] target_dir
mv [Link] [Link]
File Handling(contd...)

• 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
Pattern

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.

eg. 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]...
eg. cat [Link] [Link]
cat ­n [Link]
• echo – display a line of text
Usage: echo [OPTION] [string] ...
eg. echo I love India
echo $HOME
Text Processing(contd...)

• 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]
Text Processing(contd...)
• sort – sort lines of text files
Usage: sort [OPTION]... [FILE]...
eg. sort [Link]
sort ­r [Link]
Linux File Permissions
• 3 types of file permissions – read, write, execute
• 10 bit format from 'ls ­l' command
1 234 567 8 9 10
file type owner group others
eg. 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
eg. rwxrw­r­­ = 764
673 = rw­rwx­wx
System Administration

• chmod – change file access permissions


Usage: chmod [OPTION] [MODE] [FILE]
eg. chmod 744 [Link]
• chown – change file owner and group
Usage: chown [OPTION]... OWNER[:[GROUP]] FILE...
eg. chown remo [Link]
System Administration (contd...)

• su – change user ID or become super­user


Usage: su [OPTION] [LOGIN]
eg. su remo, 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
Process Management
• 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
Archival
• tar – to archive a file
Usage: tar [OPTION] DEST SOURCE
eg. tar ­cvf /home/[Link] /home/original
tar ­xvf /home/[Link]
• zip – package and compress (archive) files
Usage: zip [OPTION] DEST SOURSE
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] [user]@hostname
eg. ssh ­X 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 [OPTIONS] dir | device...
eg. umount /media/target
File Systems(contd...)
• 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. reboot

• poweroff – power off the system


Usage: poweroff [OPTION]
eg. poweroff
Suggested Material

• The UNIX Programming Environment


by Kernighan and Pike (PrenticeHall)
• Your UNIX: The Ultimate Guide
by Sumitabha Das
Thank You
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
• gedit ­ A text Editor. Used to create and edit files.
Usage: gedit [OPTION] [FILE]...
eg. gedit
Process Management(contd...)
• 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
Advanced Commands (contd...)

• sed ­ stream editor for filtering and transforming text


Usage: sed [OPTION] [input­file]...
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]

You might also like