SlideShare a Scribd company logo
2
Most read
6
Most read
7
Most read
LINUX BASIC
COMMANDS
PREPARED BY: - SAGAR KUMAR
Introduction to Linux
■ Open Source Operating System: -The Linux is free to use and everyone has freedom
to contribute to its development.The code used to create Linux is free and available to
the public to view, edit, and for users with the appropriate skills to contribute to.
■ Link to view Linux Kernel source code: - https://www.kernel.org/
■ Linux Kernel source code is written primarily in C andAssembly language
■ Developed by LinusTorvalds on September 17, 1991.
Architecture of Linux Operating System
Linux Basic Commands Categories
Basic commands of Linux can be categorizes into following categories: -
o SYSTEM & HARDWARE INFORMATION
o USER INFORMATION AND MANAGEMENT
o FILE AND DIRECTORY COMMANDS
o PROCESS MANAGEMENT
o FILE PERMISSIONS
o NETWORKING
o ARCHIVES (TAR FILES)
o SEARCH
o FILETRANSFERS
o FILE EDITING AND NAVIGATION INSIDE FILES
System and Hardware Information
o uname –a #Display Linux system information
Linux aa34faf8af0b 3.10.0514.26.2.el7.x86_64 #1 SMPTue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
o uname –r #Dispaly kernel release information
3.10.0-514.26.2.el7.x86_64
o uptime #for how long system has been running
11:56:15 up 14 days, 21:18, 0 users, load average: 23.14, 24.23, 24.68
o hostname #gives hostname of the system
root@ubuntu:~# hostname ubuntu
o hostname –I #gives IP address of the Host
78.31.70.238
o last reboot #to check when the system has been last rebooted
wtmp begins Sat Sep 9 10:24:23 2017
o date #display the date and time
Mon Jan 01 2018 17:17:33 GMT+0530 (India StandardTime)
o cal #display current month calendar
o free #Display the free and used memory (-h for human readable, -m for MB, -g for GB)
total used free shared buff/cache available
Mem: 263861664 11205028 205258364 1867876 47398272 233338992
Swap: 4194300 1756284 2438016
User Information and management
o w #show who is logged in and what they are doing.
12:07:00 up 14 days, 21:29, 0 users, load average: 21.66, 24.14, 24.30
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
o who #who is logged into the system
sagar tty7 2018-02-02 21:34
sagar pts/0 2018-02-02 21:35 (:0)
o whoami #who are you logged in as
[2018-01-01 17:41.43] ~
[SAGAR.workgroup] ➤ whoami
SAGAR
o id #display the current user id and group id
[2018-01-01 17:41.49] ~
[SAGAR.workgroup] ➤ id
uid=1001(SAGAR) gid=513(UsersGrp) groups=1002(HomeUsers),1004(ORA_DBA),559(Performance Log Users),545(Users)
o last #who logged in last
wtmp begins Fri Feb 2 21:53:58 2018
File and directory commands: -
o ls –al #lists all file in long listed format
o ll #actually aliased to `ls -l'
o pwd #shows present working directory
o mkdir directory_name #creates a new directory
o rmdir directory_name #deletes an empty directory
o rm –r directory_name #deletes the directory and its contents
o rm filename #deletes a file
o cp file1 file2 #copy one file to another
o mv file1 file2 #move a file/ rename a file
o touch filename #create a new file
o cat filename #displays the file contents
File permission: -
• There are 3 types of users
1. User(u) 2. Group(g) 3. Others/ World(o)
• Below are the permissions types
• Read= r
• Write= w
• Execute = x
• No access = -
• Commands to change the permissions of the file:- chmod
example:- chmod 755 filename
1/0 1/0 1/0
r = - - -
w = - - -
x = - - -
Example: rwx rwx rwx chmod 777 filename
Archives (Tar files): -
o tar -cf archive.tar directory name # Create tar named archive.tar containing directory.
o tar -xf archive_name.tar # Extract the contents from archive.tar.
o tar -czf archive.tar.gz directory name # Create a gzip compressed tar file name archive.tar.gz.
o tar -xzf archive_name.tar.gz # Extract a gzip compressed tar file.
Directory Navigation: -
o cd .. # To go up one level of the directory tree. (Change into the parent directory.)
o cd # Go to the $HOME directory
o cd /etc # Change to the /etc directory
o cd - # go back to previous directory (last accessed directory)
Process management: -
o ps #your currently running processes
o ps –ef #all the currently running processes on the system
o ps- -ef |grep processname #process information for process name
o kill pid #kill a process
o top #display and manage the top processes
o killall processname #kill all processes named there
o program & #start program in the background
o bg #display stopped or background processes
o fg #bring the most recent background job to foreground
Networking: -
o ifconfig #Displays network interface and ip address
o ping #to check given address is alive or not
o dig domain_name #display DNS information for domain
o dig –x IP_Address #Reverse lookup of IP_Address
o host domain #display DNS IP address for domain
o hostname #display the hostname
[2018-01-01 19:06.49] ~
[SAGAR.workgroup] ➤ hostname
workgroup
o netstat #Display listening tcp and udp ports and corresponding programs
– [SAGAR.workgroup] ➤ netstat
– Active Connections
– Proto Local Address Foreign Address State
– TCP 10.10.156.9:4280 hk2sch130022025:https ESTABLISHED
– TCP 10.10.156.9:4294 sb-in-f188:5228 ESTABLISHED
– TCP 10.10.156.9:6010 static:https ESTABLISHED
– TCP 10.10.156.9:9327 static:https ESTABLISHED
– TCP 10.10.156.9:9635 13.75.42.223:https TIME_WAIT
FileTransfers: -
o scp file.txt server:/tmp # Secure copy file.txt to the /tmp folder on server
o scp server:/var/www/*.html /tmp # Copy *.html files from server to the local /tmp folder.
o scp -r server:/var/www /tmp # Copy all files and directories recursively from server
to the current system's /tmp folder.
Search: -
o grep “pattern” file # Search for pattern in file
o grep -r “pattern” directory # Search recursively for pattern in directory
o locate name # Find files and directories by name
o find /home/Sagar -name 'prefix*’ # Find files in /home/Sagar that start with "prefix".
o find /home -size +250M # Find files larger than 250MB in /home
Movement within a file: -
o h, j, k ,l #left, down, up
o $ #to end of a line
o ^ #to the beginning of a line
o G #end of a file
o :1 #to the beginning of a file
o :47 #to the given line (here on 47th line)
File Editing: -
o Most common editor in Linux  vi editor
o Commands for editing files in vi editor
o vi filename # to open file in editor (Command mode)
o Press “i” # to go in INSERT mode
o double esc # moving to command mode
o :w #to save changes
o :q #to exit
o :q! #force exit
o :wq #save changes and exit
File Editing (contd…): -
o dd #remove a line
o 5dd #remove 5 lines
o u #undo last action
o :s/string #searching a string in file
o :s/string/replace #search and replace a string in current line
o :%s/string/replace #search and replace a string in whole file
o :%s/string/replace/i #search and replace a string in whole file(Case Insensitive)
Disk usages: -
o df –h # Show free and used space on mounted filesystems
o df –I # Show free and used inodes on mounted filesystems
o fdisk –l # Display disks partitions sizes and types
o du –ah # Display disk usage for all files and directories in human readable format
o du –sh # Display total disk usage off the current directory
THANK
YOU

More Related Content

PDF
Lesson 2 Understanding Linux File System
PPTX
Linux fundamentals
PPTX
Introduction to Linux
PPT
Basic command ppt
PDF
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
PPT
Linux
PPTX
Linux basics part 1
ODP
Linux commands
Lesson 2 Understanding Linux File System
Linux fundamentals
Introduction to Linux
Basic command ppt
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
Linux
Linux basics part 1
Linux commands

What's hot (20)

PPTX
Introduction 2 linux
PPT
Unix/Linux Basic Commands and Shell Script
PPT
Linux basics
PPTX
Filepermissions in linux
PDF
Course 102: Lecture 14: Users and Permissions
PPT
Basic 50 linus command
PPTX
Linux standard file system
PDF
An Introduction To Linux
PDF
Linux commands
PPTX
Linux introduction, class 1
PDF
Basic linux commands
PPTX
File permission in linux
PPTX
Linux fundamentals
PPTX
Linux architecture
PPTX
Introduction to linux
PDF
Linux Presentation
PPT
Linux - Introductions to Linux Operating System
PPTX
Linux file system
PPT
Linux basic commands
PPT
Linux file system
Introduction 2 linux
Unix/Linux Basic Commands and Shell Script
Linux basics
Filepermissions in linux
Course 102: Lecture 14: Users and Permissions
Basic 50 linus command
Linux standard file system
An Introduction To Linux
Linux commands
Linux introduction, class 1
Basic linux commands
File permission in linux
Linux fundamentals
Linux architecture
Introduction to linux
Linux Presentation
Linux - Introductions to Linux Operating System
Linux file system
Linux basic commands
Linux file system
Ad

Similar to Linux basic commands (20)

PDF
Get Started with Linux Management Command line Basic Knowledge
PDF
The Linux Command Cheat Sheet
PPTX
Linux Presentation
PPTX
Basic Linux Administration - 3.pptxon server
PPT
PDF
3.1.a linux commands reference
PDF
Linux commands cheat sheet by linoxide.com
PDF
Unix _linux_fundamentals_for_hpc-_b
PDF
Rhel 6.2 complete ebook
PDF
Linux Commands CheatSheet - PDF.pdf for engineer
PPTX
Linux commands
DOCX
Rhel 6.2 complete ebook
PDF
Linux Getting Started
PPT
Linux
PPTX
Linux for Security Professionals (Tips and Tricks) - Init 6 10/2012
PPT
Linux commands
PPT
Linux commands
PPT
Linux commands
PPT
PDF
Basics of Linux Commands, Git and Github
Get Started with Linux Management Command line Basic Knowledge
The Linux Command Cheat Sheet
Linux Presentation
Basic Linux Administration - 3.pptxon server
3.1.a linux commands reference
Linux commands cheat sheet by linoxide.com
Unix _linux_fundamentals_for_hpc-_b
Rhel 6.2 complete ebook
Linux Commands CheatSheet - PDF.pdf for engineer
Linux commands
Rhel 6.2 complete ebook
Linux Getting Started
Linux
Linux for Security Professionals (Tips and Tricks) - Init 6 10/2012
Linux commands
Linux commands
Linux commands
Basics of Linux Commands, Git and Github
Ad

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
cloud_computing_Infrastucture_as_cloud_p
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Approach and Philosophy of On baking technology
SOPHOS-XG Firewall Administrator PPT.pptx
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
A Presentation on Artificial Intelligence
Univ-Connecticut-ChatGPT-Presentaion.pdf
Machine learning based COVID-19 study performance prediction
OMC Textile Division Presentation 2021.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
1. Introduction to Computer Programming.pptx
Heart disease approach using modified random forest and particle swarm optimi...
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25-Week II
cloud_computing_Infrastucture_as_cloud_p

Linux basic commands

  • 2. Introduction to Linux ■ Open Source Operating System: -The Linux is free to use and everyone has freedom to contribute to its development.The code used to create Linux is free and available to the public to view, edit, and for users with the appropriate skills to contribute to. ■ Link to view Linux Kernel source code: - https://www.kernel.org/ ■ Linux Kernel source code is written primarily in C andAssembly language ■ Developed by LinusTorvalds on September 17, 1991.
  • 3. Architecture of Linux Operating System
  • 4. Linux Basic Commands Categories Basic commands of Linux can be categorizes into following categories: - o SYSTEM & HARDWARE INFORMATION o USER INFORMATION AND MANAGEMENT o FILE AND DIRECTORY COMMANDS o PROCESS MANAGEMENT o FILE PERMISSIONS o NETWORKING o ARCHIVES (TAR FILES) o SEARCH o FILETRANSFERS o FILE EDITING AND NAVIGATION INSIDE FILES
  • 5. System and Hardware Information o uname –a #Display Linux system information Linux aa34faf8af0b 3.10.0514.26.2.el7.x86_64 #1 SMPTue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux o uname –r #Dispaly kernel release information 3.10.0-514.26.2.el7.x86_64 o uptime #for how long system has been running 11:56:15 up 14 days, 21:18, 0 users, load average: 23.14, 24.23, 24.68 o hostname #gives hostname of the system root@ubuntu:~# hostname ubuntu o hostname –I #gives IP address of the Host 78.31.70.238 o last reboot #to check when the system has been last rebooted wtmp begins Sat Sep 9 10:24:23 2017 o date #display the date and time Mon Jan 01 2018 17:17:33 GMT+0530 (India StandardTime) o cal #display current month calendar o free #Display the free and used memory (-h for human readable, -m for MB, -g for GB) total used free shared buff/cache available Mem: 263861664 11205028 205258364 1867876 47398272 233338992 Swap: 4194300 1756284 2438016
  • 6. User Information and management o w #show who is logged in and what they are doing. 12:07:00 up 14 days, 21:29, 0 users, load average: 21.66, 24.14, 24.30 USER TTY LOGIN@ IDLE JCPU PCPU WHAT o who #who is logged into the system sagar tty7 2018-02-02 21:34 sagar pts/0 2018-02-02 21:35 (:0) o whoami #who are you logged in as [2018-01-01 17:41.43] ~ [SAGAR.workgroup] ➤ whoami SAGAR o id #display the current user id and group id [2018-01-01 17:41.49] ~ [SAGAR.workgroup] ➤ id uid=1001(SAGAR) gid=513(UsersGrp) groups=1002(HomeUsers),1004(ORA_DBA),559(Performance Log Users),545(Users) o last #who logged in last wtmp begins Fri Feb 2 21:53:58 2018
  • 7. File and directory commands: - o ls –al #lists all file in long listed format o ll #actually aliased to `ls -l' o pwd #shows present working directory o mkdir directory_name #creates a new directory o rmdir directory_name #deletes an empty directory o rm –r directory_name #deletes the directory and its contents o rm filename #deletes a file o cp file1 file2 #copy one file to another o mv file1 file2 #move a file/ rename a file o touch filename #create a new file o cat filename #displays the file contents
  • 8. File permission: - • There are 3 types of users 1. User(u) 2. Group(g) 3. Others/ World(o) • Below are the permissions types • Read= r • Write= w • Execute = x • No access = - • Commands to change the permissions of the file:- chmod example:- chmod 755 filename 1/0 1/0 1/0 r = - - - w = - - - x = - - - Example: rwx rwx rwx chmod 777 filename
  • 9. Archives (Tar files): - o tar -cf archive.tar directory name # Create tar named archive.tar containing directory. o tar -xf archive_name.tar # Extract the contents from archive.tar. o tar -czf archive.tar.gz directory name # Create a gzip compressed tar file name archive.tar.gz. o tar -xzf archive_name.tar.gz # Extract a gzip compressed tar file.
  • 10. Directory Navigation: - o cd .. # To go up one level of the directory tree. (Change into the parent directory.) o cd # Go to the $HOME directory o cd /etc # Change to the /etc directory o cd - # go back to previous directory (last accessed directory)
  • 11. Process management: - o ps #your currently running processes o ps –ef #all the currently running processes on the system o ps- -ef |grep processname #process information for process name o kill pid #kill a process o top #display and manage the top processes o killall processname #kill all processes named there o program & #start program in the background o bg #display stopped or background processes o fg #bring the most recent background job to foreground
  • 12. Networking: - o ifconfig #Displays network interface and ip address o ping #to check given address is alive or not o dig domain_name #display DNS information for domain o dig –x IP_Address #Reverse lookup of IP_Address o host domain #display DNS IP address for domain o hostname #display the hostname [2018-01-01 19:06.49] ~ [SAGAR.workgroup] ➤ hostname workgroup o netstat #Display listening tcp and udp ports and corresponding programs – [SAGAR.workgroup] ➤ netstat – Active Connections – Proto Local Address Foreign Address State – TCP 10.10.156.9:4280 hk2sch130022025:https ESTABLISHED – TCP 10.10.156.9:4294 sb-in-f188:5228 ESTABLISHED – TCP 10.10.156.9:6010 static:https ESTABLISHED – TCP 10.10.156.9:9327 static:https ESTABLISHED – TCP 10.10.156.9:9635 13.75.42.223:https TIME_WAIT
  • 13. FileTransfers: - o scp file.txt server:/tmp # Secure copy file.txt to the /tmp folder on server o scp server:/var/www/*.html /tmp # Copy *.html files from server to the local /tmp folder. o scp -r server:/var/www /tmp # Copy all files and directories recursively from server to the current system's /tmp folder.
  • 14. Search: - o grep “pattern” file # Search for pattern in file o grep -r “pattern” directory # Search recursively for pattern in directory o locate name # Find files and directories by name o find /home/Sagar -name 'prefix*’ # Find files in /home/Sagar that start with "prefix". o find /home -size +250M # Find files larger than 250MB in /home
  • 15. Movement within a file: - o h, j, k ,l #left, down, up o $ #to end of a line o ^ #to the beginning of a line o G #end of a file o :1 #to the beginning of a file o :47 #to the given line (here on 47th line)
  • 16. File Editing: - o Most common editor in Linux  vi editor o Commands for editing files in vi editor o vi filename # to open file in editor (Command mode) o Press “i” # to go in INSERT mode o double esc # moving to command mode o :w #to save changes o :q #to exit o :q! #force exit o :wq #save changes and exit
  • 17. File Editing (contd…): - o dd #remove a line o 5dd #remove 5 lines o u #undo last action o :s/string #searching a string in file o :s/string/replace #search and replace a string in current line o :%s/string/replace #search and replace a string in whole file o :%s/string/replace/i #search and replace a string in whole file(Case Insensitive)
  • 18. Disk usages: - o df –h # Show free and used space on mounted filesystems o df –I # Show free and used inodes on mounted filesystems o fdisk –l # Display disks partitions sizes and types o du –ah # Display disk usage for all files and directories in human readable format o du –sh # Display total disk usage off the current directory