SlideShare a Scribd company logo
Linux commands
Creating Files
touch file To update the timestamp of file (if file exit) Create
an empty file (if doesn’t exit)
touch a b c To create multiple files a b c
touch {1..10} To create file from 1 to 10
touch {a..z} To create files from a to z
touch file {1..10} Creates file1, file2… file10
cat > file Create file
If file exist: Overwrite
If file doesn’t exist: creates new
cat >> file Create file
If file exist: append
If file doesn’t exist: creates new
vi file Open a file in vi editor
To Logout To Shutdown To Reboot
ctrl + d init 0 init 6
logout halt reboot
exit shutdown –h o shutdown –r o
Help Commands
man command Manual of Command
whatis command Definition of command
info command Information about command
command --help Help details of command
To Display files
cat file Display file
cat –n files Display files with line numbers
more file Display file from starting line (page by
page)
less file Same as more *
head file Display 1st 10 lines of file
head –n file Display n number of lines from starting
line of file
tail file Display bottom 10 lines
tail –n file Display n number of files (bottom)
tail –f file Display bottom lines dynamically
File operations
cat file1 > file1 overwrite the file2 with file 1 contents
cat file1 >> file2 append file1 contents to file2
rm –f file1 file2 file3 remove files
cp file1 file2 copy file1 to file2
mv oldfile newfile move or rename file
To create Directories
mkdir dir Creates directory with name dir
mkdir –p main/sub To create parent and sub directory
mkdir –p a/b/c To create multiple hierarchy
mkdir –p main/{sub1,sub2} Crates sub1 and sub2 inside main
To List the directory contents
ls List contents of current directory
ls –l Long list
ls –a List including hidden files (.files)
ls -t Modification time based listing
ls –r Reverse listing
ls –ltr Long list, time based, reverse order listing
ls / List contents under /
ls /tmp List contents under /tmp
Process
ps Display currently active process
ps –ef Display detailed info about process
pstree Shows running process as tree
top Display all running processes
ps –eo pid,ppid,pcpu,comm Print processes details in customized format
kill pid Kill process using pic
kill -9 pid Force kill the given process id
pkill pname Kill process supplying process name
killall name Kill all processes with names beginning name
Word count
wc file Displays no of (lines, words, characters)
wc –l file Displays no of lines
wc –w file Displays no of words
wc –c file Display no of characters
Keyboard shortcuts
Ctrl +a Moves cursor to start of line
Ctrl + b Moves cursor to one character backwards
Ctrl + c Terminate the current line without executing
Ctrl + d Close current shell
Ctrl + e Moves cursor point to end of line
Ctrl + f Moves cursor one character forward
Ctrl + g Cancel the search and restore the original line
Ctrl + h Delete previous character
Ctrl + j Acts as enter button
Ctrl + k Deletes the line from cursor point to end of line
Ctrl + l Clear the screen
Ctrl + r Reverse search history
Ctrl + u Delete the entire line before cursor point
Ctrl + y Yank the content from current position
Ctrl + z Stop / suspend the current running process
Filter commands
grep –i pattern filename To search for a pattern in a file
grep –v pattern file name To print the lines in a file except the matching line
egrep –i “pat1|pat2” file Print the lines using multiple pattern match
command 1 | command2 Pipe symbol; stdout of command1 to command 2
fine To find and processing files
find –name Name of file or dir
find –iname Ignore case name
find –user To find user
find –group To find group
find –uid To find using uid
find –gid To find files using gid
find –perm To print files based on permission
find –ctime Find files based on creation time
find –aime Find files based on access time
find -ctime Find files based on creation time
find -seze Find files based on size of file
Network
ping hostname Ping host and output the result
ssh hostname
ssh ipaddress
ssh username@hostname
ssh usename@ipaddress
Ssh into the remote server
dig hostname Query dns info
dig –x hostname Reverse lookup host
wget file To download the file
ifconfig Config network interface and to view network info
ethtool eth0 Query/control network driver and hardware settings
ifup eth0 Enable eth0 interface
ifdown eht0 Disable eth0 interface
tracerout Print the route packets trace to network host
netstat Display connection info, routing table info etc
nslookup Query internet name servers interactively
Disk related commands
df –h Report file system disk space usage
df –ht Shows file system type
df –ih Shows inode usage
lsblk List block devices
blkid Print block device attributes
fdisk –l List available partitions
cat /proc/partitions To print read only file system
grep –w ro /proc/mounts To check whether mount point has ROFS issue
lsscsi List scsi devices on host
mkfs To create file system
e2label To label the partiion
smartctl –h /dev/sdb To conduct smartctl test on device
smartctl –i /dev/sdb To see the detailed info about drive
hdparm –l /dev/sdx To print h/w parameters of drive
At job
tty To check the console
at time To schedule job
at –l (or) atq To check the list of at jobs
at –c jobid To check what is scheduled
atrm jobid To remove a job
/etc/at.deny If add any single user in deny file
only that user can be deny
/etc/at.allow If add any single user in allow file
then remaining all users will be
blocked/deny
crontab
crontab format Minute(0-59) hour(0-23) day of month(1 – 31) month of
the year(1 -12) day of week (0-6) command to be executed
* All possible values
* */2 * * * It treated as every 2 hours
*/5 * * * * It treated as every 5 minutes
crontab –e Edit crontab file
crontab –l To check the cron jobs
crontab –l –u username To check the cron jobs of particular user
crontab –r To remove crontab files
@yearly Every year
@monthly Every month
@daily Every day
Managing Services
services service name status To check the status of service
service servicename stop To stop the running service
service servicename restart To restart the service
service servicename reload To reload/refresh the service
chkconfig –list To display available services
chkconfig –list |grep –i service To display specific service
chkconfig service on To make service enabled at boot time
chkconfig service off to make service off at boot time
chkconfig service on –level 12345 To make service level on across
runlevels
Group management
/etc/group It will store all group information
/etc/gshadow It will store all group password information
groupadd groupname Create group name
groupadd –g gid groupname Create group with user specified group id
groupmod –g gid groupname To change group id
groupmod –n newname oldname To change group name
groupdel groupname To delete group account
gpasswd groupname To set group password
gpasswd –r group name To delete group password
gpasswd –a username groupname To add single user into group
gpasswd –m user1,user2 groupname To add multiple users into group
gpasswd –d username groupname To delete user with particular group
User management
/etc/passwd It will store all user information
/etc/shadow It will store all user password information
useradd username Add a user
passwd username Assigning password to the user
usermod –l newname oldname To change user name
usermod –u newid username To change user id
usermod -g newgid username To change group id
usermod –c “hello” username To change comment
usermod –d /home/newname username To change home directory name
usermod -s /bin/newshell username To change the shell
id username To display uid,gid & groups for user (or ) it will give group
names
groups username To display only groups in particular user
passwd –l username To lock user
passwd –u username To unlock user
passwd –d username To remove/delete password
passwd –s username To check the user is locked or not
USER MANAGEMENT
userdel username Only delete user account
userdel –r username To delete user account including all files
passwd –x –l username To set the passwd never expiry
chage –l username To see the user password information
chage username To set the password user
chage –f username Force to change password for first time
login
usermod –g group1,group2 username One user can add into multiple groups
id –a username to check primary and secondary group of
user
usermod –yy—dd—mm username to set expire date for user or account
usermod –g gid username to change secondary group name
YUM(YELLOWDOG UPDATED MODIFIED)
/etc/yum.repos.d/ To create local repository
yum clean all Like clean or refresh the package
yum list available to check our repository is functioning or not
yum list to list all available packages
yum install packagename To install package
yum install packagename –y To install package without prompt y/n
yum install packagename To install multiple packages at a time
yum remove packagename To remove (or) uninstall the package
yum remove packagename –y To remove package without prompt y/n
yum list installed to see all installed packages
yum list install packagename To see particular package is installed or not
yum info packagename To information of installed package
yum update packagename To update the package
yum repolist To see available repo lists
yum depist packagename It will display how many dependencies there in package
yum repolist all We can see repo is enabled or disabled
yum install packagename –skip –broken To install package no dependency (incase error will occur ie no dependency
package)
yum install –downloadonly packagename It will download package only not install
yum info packagename To display package information
yum –downgrade packagename To download the package
RPM (REDHAT PACKAGE MANAGER)
rpm –qa packagename to check all installed packages
rpm –ivh packagename(v =verbose, h=hash) To install the rpm package
rpm –ivh packagename --force To install the package forcefully
rpm-ivh packganame --nodeps To install the package without dependency
rpm packagename
rpm –qa |grep –i packgaename
to check the package is installed (or) not
rpm –qi packagename to see the information about installed package
rpm –qc packagename to see the configuration file about installed package
rpm –qd packagename to see the directory with which package is associated
rpm –u packagename Upgrade the package if package exit upgrade the
package if not exit install the package
rpm –F packagename Update the package if package exit update the
package if not exit skip the package
rpm –V packagename Verify the package if any file are missing
rpm –e packagename to remove/erase the package
Linux commands

More Related Content

PDF
Linux Bash Shell Cheat Sheet for Beginners
PDF
Linux cheat-sheet
PDF
Unix Command-Line Cheat Sheet BTI2014
DOCX
Linux basic commands
DOCX
List command linux fidora
PPTX
Basic unix commands
PDF
One Page Linux Manual
PDF
Linux command line
Linux Bash Shell Cheat Sheet for Beginners
Linux cheat-sheet
Unix Command-Line Cheat Sheet BTI2014
Linux basic commands
List command linux fidora
Basic unix commands
One Page Linux Manual
Linux command line

What's hot (17)

PDF
PDF
[PDF] 2021 Termux basic commands list
ODT
Terminal linux commands_ Fedora based
PDF
Rhel 6.2 complete ebook
PDF
Termux commands-list
DOCX
Rhel 6.2 complete ebook
PDF
Linux commands cheat sheet by linoxide.com
DOC
Unix Basics For Testers
PDF
Unix / Linux Command Reference
PPTX
Basics of unix
PPTX
Linux And perl
PDF
Basic commands
PPTX
Unix slideshare
DOCX
Linux midterm quiz
PDF
Presentation aix basic
PDF
PDF
Basic shell programs assignment 1_solution_manual
[PDF] 2021 Termux basic commands list
Terminal linux commands_ Fedora based
Rhel 6.2 complete ebook
Termux commands-list
Rhel 6.2 complete ebook
Linux commands cheat sheet by linoxide.com
Unix Basics For Testers
Unix / Linux Command Reference
Basics of unix
Linux And perl
Basic commands
Unix slideshare
Linux midterm quiz
Presentation aix basic
Basic shell programs assignment 1_solution_manual
Ad

Similar to Linux commands (20)

PDF
3.1.a linux commands reference
PDF
The Linux Command Cheat Sheet
PDF
Quick guide of the most common linux commands
PDF
Linux Commands CheatSheet - PDF.pdf for engineer
PPT
Linux
DOCX
40 important command for linux
PPT
Linux ppt
PDF
Comenzi unix
PDF
Linux cheat-sheet
PDF
Linux Commandos Cheat
PPTX
Introduction to linux day1
DOCX
Really useful linux commands
PPTX
Basic unix
TXT
An a z index of the bash commands
PPTX
Linux Fundamentals
PPT
Common linux ubuntu commands overview
PPT
DOCX
List command linux a z
PDF
KALI-LINUX-COMMANDS.pdf.................
DOCX
Basic linux commands
3.1.a linux commands reference
The Linux Command Cheat Sheet
Quick guide of the most common linux commands
Linux Commands CheatSheet - PDF.pdf for engineer
Linux
40 important command for linux
Linux ppt
Comenzi unix
Linux cheat-sheet
Linux Commandos Cheat
Introduction to linux day1
Really useful linux commands
Basic unix
An a z index of the bash commands
Linux Fundamentals
Common linux ubuntu commands overview
List command linux a z
KALI-LINUX-COMMANDS.pdf.................
Basic linux commands
Ad

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A Presentation on Artificial Intelligence
Dropbox Q2 2025 Financial Results & Investor Presentation
Network Security Unit 5.pdf for BCA BBA.
Digital-Transformation-Roadmap-for-Companies.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
NewMind AI Weekly Chronicles - August'25 Week I
20250228 LYD VKU AI Blended-Learning.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Chapter 3 Spatial Domain Image Processing.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...

Linux commands

  • 2. Creating Files touch file To update the timestamp of file (if file exit) Create an empty file (if doesn’t exit) touch a b c To create multiple files a b c touch {1..10} To create file from 1 to 10 touch {a..z} To create files from a to z touch file {1..10} Creates file1, file2… file10 cat > file Create file If file exist: Overwrite If file doesn’t exist: creates new cat >> file Create file If file exist: append If file doesn’t exist: creates new vi file Open a file in vi editor
  • 3. To Logout To Shutdown To Reboot ctrl + d init 0 init 6 logout halt reboot exit shutdown –h o shutdown –r o Help Commands man command Manual of Command whatis command Definition of command info command Information about command command --help Help details of command
  • 4. To Display files cat file Display file cat –n files Display files with line numbers more file Display file from starting line (page by page) less file Same as more * head file Display 1st 10 lines of file head –n file Display n number of lines from starting line of file tail file Display bottom 10 lines tail –n file Display n number of files (bottom) tail –f file Display bottom lines dynamically
  • 5. File operations cat file1 > file1 overwrite the file2 with file 1 contents cat file1 >> file2 append file1 contents to file2 rm –f file1 file2 file3 remove files cp file1 file2 copy file1 to file2 mv oldfile newfile move or rename file To create Directories mkdir dir Creates directory with name dir mkdir –p main/sub To create parent and sub directory mkdir –p a/b/c To create multiple hierarchy mkdir –p main/{sub1,sub2} Crates sub1 and sub2 inside main
  • 6. To List the directory contents ls List contents of current directory ls –l Long list ls –a List including hidden files (.files) ls -t Modification time based listing ls –r Reverse listing ls –ltr Long list, time based, reverse order listing ls / List contents under / ls /tmp List contents under /tmp
  • 7. Process ps Display currently active process ps –ef Display detailed info about process pstree Shows running process as tree top Display all running processes ps –eo pid,ppid,pcpu,comm Print processes details in customized format kill pid Kill process using pic kill -9 pid Force kill the given process id pkill pname Kill process supplying process name killall name Kill all processes with names beginning name
  • 8. Word count wc file Displays no of (lines, words, characters) wc –l file Displays no of lines wc –w file Displays no of words wc –c file Display no of characters
  • 9. Keyboard shortcuts Ctrl +a Moves cursor to start of line Ctrl + b Moves cursor to one character backwards Ctrl + c Terminate the current line without executing Ctrl + d Close current shell Ctrl + e Moves cursor point to end of line Ctrl + f Moves cursor one character forward Ctrl + g Cancel the search and restore the original line Ctrl + h Delete previous character Ctrl + j Acts as enter button Ctrl + k Deletes the line from cursor point to end of line Ctrl + l Clear the screen Ctrl + r Reverse search history Ctrl + u Delete the entire line before cursor point Ctrl + y Yank the content from current position Ctrl + z Stop / suspend the current running process
  • 10. Filter commands grep –i pattern filename To search for a pattern in a file grep –v pattern file name To print the lines in a file except the matching line egrep –i “pat1|pat2” file Print the lines using multiple pattern match command 1 | command2 Pipe symbol; stdout of command1 to command 2 fine To find and processing files find –name Name of file or dir find –iname Ignore case name find –user To find user find –group To find group find –uid To find using uid find –gid To find files using gid find –perm To print files based on permission find –ctime Find files based on creation time find –aime Find files based on access time find -ctime Find files based on creation time find -seze Find files based on size of file
  • 11. Network ping hostname Ping host and output the result ssh hostname ssh ipaddress ssh username@hostname ssh usename@ipaddress Ssh into the remote server dig hostname Query dns info dig –x hostname Reverse lookup host wget file To download the file ifconfig Config network interface and to view network info ethtool eth0 Query/control network driver and hardware settings ifup eth0 Enable eth0 interface ifdown eht0 Disable eth0 interface tracerout Print the route packets trace to network host netstat Display connection info, routing table info etc nslookup Query internet name servers interactively
  • 12. Disk related commands df –h Report file system disk space usage df –ht Shows file system type df –ih Shows inode usage lsblk List block devices blkid Print block device attributes fdisk –l List available partitions cat /proc/partitions To print read only file system grep –w ro /proc/mounts To check whether mount point has ROFS issue lsscsi List scsi devices on host mkfs To create file system e2label To label the partiion smartctl –h /dev/sdb To conduct smartctl test on device smartctl –i /dev/sdb To see the detailed info about drive hdparm –l /dev/sdx To print h/w parameters of drive
  • 13. At job tty To check the console at time To schedule job at –l (or) atq To check the list of at jobs at –c jobid To check what is scheduled atrm jobid To remove a job /etc/at.deny If add any single user in deny file only that user can be deny /etc/at.allow If add any single user in allow file then remaining all users will be blocked/deny
  • 14. crontab crontab format Minute(0-59) hour(0-23) day of month(1 – 31) month of the year(1 -12) day of week (0-6) command to be executed * All possible values * */2 * * * It treated as every 2 hours */5 * * * * It treated as every 5 minutes crontab –e Edit crontab file crontab –l To check the cron jobs crontab –l –u username To check the cron jobs of particular user crontab –r To remove crontab files @yearly Every year @monthly Every month @daily Every day
  • 15. Managing Services services service name status To check the status of service service servicename stop To stop the running service service servicename restart To restart the service service servicename reload To reload/refresh the service chkconfig –list To display available services chkconfig –list |grep –i service To display specific service chkconfig service on To make service enabled at boot time chkconfig service off to make service off at boot time chkconfig service on –level 12345 To make service level on across runlevels
  • 16. Group management /etc/group It will store all group information /etc/gshadow It will store all group password information groupadd groupname Create group name groupadd –g gid groupname Create group with user specified group id groupmod –g gid groupname To change group id groupmod –n newname oldname To change group name groupdel groupname To delete group account gpasswd groupname To set group password gpasswd –r group name To delete group password gpasswd –a username groupname To add single user into group gpasswd –m user1,user2 groupname To add multiple users into group gpasswd –d username groupname To delete user with particular group
  • 17. User management /etc/passwd It will store all user information /etc/shadow It will store all user password information useradd username Add a user passwd username Assigning password to the user usermod –l newname oldname To change user name usermod –u newid username To change user id usermod -g newgid username To change group id usermod –c “hello” username To change comment usermod –d /home/newname username To change home directory name usermod -s /bin/newshell username To change the shell id username To display uid,gid & groups for user (or ) it will give group names groups username To display only groups in particular user passwd –l username To lock user passwd –u username To unlock user passwd –d username To remove/delete password passwd –s username To check the user is locked or not
  • 18. USER MANAGEMENT userdel username Only delete user account userdel –r username To delete user account including all files passwd –x –l username To set the passwd never expiry chage –l username To see the user password information chage username To set the password user chage –f username Force to change password for first time login usermod –g group1,group2 username One user can add into multiple groups id –a username to check primary and secondary group of user usermod –yy—dd—mm username to set expire date for user or account usermod –g gid username to change secondary group name
  • 19. YUM(YELLOWDOG UPDATED MODIFIED) /etc/yum.repos.d/ To create local repository yum clean all Like clean or refresh the package yum list available to check our repository is functioning or not yum list to list all available packages yum install packagename To install package yum install packagename –y To install package without prompt y/n yum install packagename To install multiple packages at a time yum remove packagename To remove (or) uninstall the package yum remove packagename –y To remove package without prompt y/n yum list installed to see all installed packages yum list install packagename To see particular package is installed or not yum info packagename To information of installed package yum update packagename To update the package yum repolist To see available repo lists yum depist packagename It will display how many dependencies there in package yum repolist all We can see repo is enabled or disabled yum install packagename –skip –broken To install package no dependency (incase error will occur ie no dependency package) yum install –downloadonly packagename It will download package only not install yum info packagename To display package information yum –downgrade packagename To download the package
  • 20. RPM (REDHAT PACKAGE MANAGER) rpm –qa packagename to check all installed packages rpm –ivh packagename(v =verbose, h=hash) To install the rpm package rpm –ivh packagename --force To install the package forcefully rpm-ivh packganame --nodeps To install the package without dependency rpm packagename rpm –qa |grep –i packgaename to check the package is installed (or) not rpm –qi packagename to see the information about installed package rpm –qc packagename to see the configuration file about installed package rpm –qd packagename to see the directory with which package is associated rpm –u packagename Upgrade the package if package exit upgrade the package if not exit install the package rpm –F packagename Update the package if package exit update the package if not exit skip the package rpm –V packagename Verify the package if any file are missing rpm –e packagename to remove/erase the package