SlideShare a Scribd company logo
Linux
Command
By Vineeta
LINUX COMMAND
man: man command in Linux is used to display the user manual of
any command that we can run on the terminal. It provides a detailed
view of the command which includes NAME, SYNOPSIS,
DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES,
ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE
ALSO.
COMMAND : man ls
pwd : Print Work Directory
pwd stands for Print Working Directory. It prints the path of the working directory,
starting from the root.
To check the version of pwd
Command : /bin/pwd --version
cal command
This command display the calendar of current month.
ncal
Comand : ncal
Command: cal -m1 , cal -m2 , cal -m3 ...
Command: cal -y year / cal -y 2020
date
Command : date
Displays current time and date.
whoami
Command : whoami
This command reveals the user who is currently logged in.
whatis
Command : whatis ls / whatis date
This command gives a one line description about the command. It can be used as a
quick reference for any command.
w
Command : w
The w command lists the currently logged in users.
id
Command: id / id (root) by passing username as argument
This command prints user and groups (UID and GID) of the current user.
UID : User Identifier
A UID (user identifier) is a number assigned by Linux to each user on the system. This
number is used to identify the user to the system and to determine which system resources
the user can access.
● UID 0 (zero) is reserved for the root.
● UIDs 1–99 are reserved for other predefined accounts.
● UID 100–999 are reserved by system for administrative and system
accounts/groups.
● UID 1000–10000 are occupied by applications account.
● UID 10000+ are used for user accounts.
GID : Group Id
Groups in Linux are defined by GIDs (group IDs).
● GID 0 (zero) is reserved for the root group.
● GID 1–99 are reserved for the system and application use.
● GID 100+ allocated for the user’s group.
clear
This command clears the screen
Command : clear
Shortcut : ctrl+L
ps
The ps command lists running processes. Using ps without any
options causes it to list the processes running in the current shell.
Command : ps
history
The history command lists the commands you have previously
issued on the command line. You can repeat any of the commands
from your history by typing an exclamation point ! and the number
of the command from the history list
Command : history
mkdir
The mkdir command allows you to create new directories in the filesystem. You must
provide the name of the new directory to mkdir. If the new directory is not going to be
within the current directory, you must provide the path to the new directory.
Command : mkdir os / mkdir os cpp ds
Linux Command.pptx
Linux version
Uname to check the version of linux.
-v 0r --verbose
It displays a message for every directory created.
Command: mkdir -v 1 2 3
-p
A flag which enables the command to create parent directories as necessary. If the
directories exist, no error is specified.
Command: mkdir -p dss/ds/d
To create files
Create a file with touch command
We will use touch command with any extension to create file, this command will
create an empty file test.txt in your current directory
Command : touch file.txt
Create a file with cat command
cat command to create file, this command will create an empty file in your current
directory, but you must add text in the file.
Command: cat > testcat.txt
This file has been created with cat command
To save the file hit Ctrl + d and to check whether it is present in your directory or not
Command : ls -l testcat.txt
Linux Command.pptx
Create a file with echo command
echo command to create file, this command will create a file in the current directory but
you should add text in the line command.
Command : echo "check echo" > testecho.txt
To see the file,type command below.
Command: ls -l testecho.txt
Linux Command.pptx
Create a file with printf command
We will use printf command to create file, this command will create a file printf.txt in your
current directory as an example below, but you should add text in the line command.
Command: printf "This file has been created with printf command" > printf.txt
To see the file type command below.
Command: ls -l printf.txt
Linux Command.pptx
Create a file using nano
To create a file using nano text editor, first install it, after that type command below and
the text editor will be opened to adding text.
Command : nano nano.txt
Add the text below.
This file has been created with nano text editor
To save the file type Ctrl + x and type y, to see the file type command below.
Command: ls -l nano.txt
Linux Command.pptx
Create a file with vi editor
To create a file using vi text editor, type command below and the text editor will open the
file, but you can't add any text before converting it to insert mode by typing i character.
Command: vi vi.txt
Add the text below.
This file has been created with vi text editor
To save the file and exit hit Esc after that :wq, To see the file type command below.
Command : ls -l vi.txt
Linux Command.pptx
Create a file with vim text editor
To create a file using vim text editor, type command below and the text editor will open
the file, but you can't add any text before converting it to insert mode by typing i character.
Command : vim vim.txt
Add the text below.
This file has been created with vim text editor
To save the file and exit hit Esc after that :wq, to see the file type command below.
Command : ls -l vim.txt
How to remove a file
To remove (or delete) a file in Linux from the command line, use either the rm (remove)
or unlink command.
To delete a single file, use the rm or unlink command followed by the file name:
Command : unlink filename / rm filename
Linux Command.pptx
To delete a file
To delete multiple files at once, use the rm command followed by the file names separated
by space.
Command :rm filename1 filename2 filename3
You can also use a wildcard (*) and regular expansions to match
multiple files. For example, to remove all .pdf files in the current
directory, use the following command:
Command : rm *.pdf / rm *.txt
● Use the rm with the -i option to confirm each file before deleting it:
Command : rm -i filename(s)
● To remove files without prompting even if the files are write-protected pass the -f
(force) option to the rm command:
Command : rm -f filename(s)
rm -i filename
Delete a empty directory
use ‘-d‘ option in rm command to delete a empty directory.
Command : rm -d appdata/
You can also combine rm options. For example, to remove all .txt files in the current
directory without a prompt in verbose mode, use the following command:
Command: rm -fv *.txt
How to remove directory
In Linux, you can remove/delete directories with the rmdir and rm.
rmdir is a command-line utility for deleting empty directories while with rm you can
remove directories and their contents recursively.
To remove an empty directory, use either rmdir or rm -d followed by the directory name:
Command: rm -d dirname
rmdir dirname
-r‘ option in rm command will delete all the files and sub-directories recursively of
the parent directory.
rm -r dirname
Delete the files and sub-directories interactively.
Use ‘-ri‘ option in rm command to delete file and sub-directories interactively,
Rm -ri dbstore
To remove non-empty directories and all the files without being prompted, use rm
with the -r (recursive) and -f options:rm -rf dirname
To remove multiple directories at once, use the rm -r command followed by the
directory names separated by space.
Command : rm -r dirname1 dirname2 dirname3
Delete large number files using rm
command
If your are trying to delete large number of files using rm command then you will get
an error message ‘Argument list too long’
rm *.log
Copy command
Cp command is use to copy a file from source to destination
Command :Cp target_file to source file
Copy a file interactively
If you wish to copy the files from one place to another interactively then use the “-i”
option in cp command, interactive option only works if the destination directory
already has the same file, example is shown below,
Command : cp -i filename
Copy a directory or folder (-r 0r -R)
To copy a directory from one place to another use -r or -R option in cp command. Let’s
assume we want to copy the home directory of linuxtechi user to “/mn/backup”,
Command : cp -r /home/linuxtechi /mnt/backup/
Do not overwrite the existing file while copying (-n)
cp -n /etc/passwd /mnt/backup/
Mv command
move a file
To move a file using the mv command pass the name of the file and then the new name for
the file. In the following example the file foo.txt is renamed to bar.txt.
mv foo.txt bar.txt
Move a file into a directory
To move a file into a directory using the mv command pass the name of the file and then
the directory. In the following example the file foo.txt is moved into the directory bar.
mv foo.txt bar
How to move multiple file into a directory
To move multiple files using the mv command pass the names of the files or a pattern
followed by the destination.
mv file1.txt file.2.txt file3.txt folder
The following example is the same as above but uses pattern matching to move all files
with a .txt extension.
mv *.txt folder
Move a directory
To move a directory using the mv command pass the name of the directory to move
followed by the destination.
mv foo bar
How to prompt before overwriting a file
mv -i foo.txt bar.txt
How to not overwrite an existing file
To prevent an existing file from being overwritten pass the -n option
mv -n foo.txt bar.txt
How to take a backup of an existing file
To take a backup of an existing file that will be overwritten as a result of the mv
command pass the -b option. This will create a backup file with the tilde character
appended to it.
mv -b foo.txt bar.txt
grep
The grep utility searches for lines which contain a search pattern. When we looked at the
alias command, we used grep to search through the output of another program, ps . The
grep command can also search the contents of files.
grep train *.txt
gzip
The gzip command compresses files. By default, it removes the original file and leaves
you with the compressed version. To retain both the original and the compressed
version, use the -k (keep) option.
gzip -k core.c
head
head command gives you a listing of the first 10 lines of a file. If
you want to see fewer or more lines, use the -n (number) option. In
this example, we use head with its default of 10 lines. We then
repeat the command asking for only five lines.
Head -n 5 test.txt
tail
The tail command gives you a listing of the last 10 lines of a file. If you want to see
fewer or more lines, use the -n (number) option. In this example, we use tail with its
default of 10 lines. We then repeat the command asking for only five lines.
tail core.c
tail -n 5 core.c
less
The less command allows you to view files without opening an editor. It’s faster to use,
and there’s no chance of you inadvertently modifying the file. With less you can scroll
forward and backward through the file using the Up and Down Arrow keys, the PgUp and
PgDn keys and the Home and End keys. Press the Q key to quit from less.
To view a file provide its name to less as follows:
less core.c
ssh
Use the ssh command to make a connection to a remote Linux
computer and log into your account. To make a connection, you
must provide your user name and the IP address or domain name of
the remote computer. In this example, the user mary is logging into
the computer at 192.168.4.23.
ssh mary@192.168.4.23
Cd command
The cd command is used to change the current directory (i.e., the directory in which the
user is currently working) in Linux
Navigate to the Previous Directory
To change back to the previous working directory, pass the dash (-) character as an argument to the cd
command:
cd -
Navigate to the Home Directory
To navigate to your home directory simply type cd. Another way to return directly to your
home directory is to use the tilde (~) character, as shown below:
cd ~
Ls command
Ls command shows the list of files and directories , where you won’t be able to view
details like file types, size, modified date and time, permission and links etc.
ls --version
1. A. ls -l shows file or directory, size, modified date and time, file or folder name
and owner of file and its permission.
ls > output.txt
cat output.txt:
Linux Command.pptx
1. B. View Hidden Files:
ls -a : contains the list of all the hidden file including “ .” and “. .”
1. C. List Files with Human Readable Format
ls -lh : contains all the option which can be understood by non development person.
1. D. Sort Files by Files size
ls -lS / ls -S -l: displays file size in order of bigger size first.
ls -i :
i over here is to check Inode Informations.
An inode is a data structure that stores various information about a file in Linux, such
as the access mode (read, write, execute permissions), ownership, file type, file size,
group, number of links, etc. Each inode is identified by an integer number. An inode
is assigned to a file when it is created.
ls -R :
You can list directories recursively using ls -R.
Recursively means it will list all the directory with is all subdirectory in a tree format.
ls -lt :
Linux ls command with -t will list the files and directories by it’s modification date in
ascending order, means the higher will be come first.
ls ~ : command to list the contents in the user's home directory.
ls -d */ command to list only directories:
ls * command to list the contents of the directory with it's subdirectories
ls -S (the S is uppercase) : command to list files or directories and sort by date or time in
descending order (biggest to smallest).
You can also add a -r flag to reverse the sorting order like so: ls -Sr
ls -n: ls command with option -n will show the UID (User ID) and GID (Group ID) numbers of file and directory.
A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to
determine which system resources the user can access.
● UID 0 (zero) is reserved for the root.
● UIDs 1–99 are reserved for other predefined accounts.
● UID 100–999 are reserved by system for administrative and system accounts/groups.
● UID 1000–10000 are occupied by applications account.
● UID 10000+ are used for user accounts.
GID
Groups in Linux are defined by GIDs (group IDs).
● GID 0 (zero) is reserved for the root group.
● GID 1–99 are reserved for the system and application use.
● GID 100+ allocated for the user’s group.
ls -G
If you want to list only Owner of the files and directories to which they are belongs and not groups then use Linux ls command
with argument -G.
There are three permissions groups:
1. Owner
2. Group
3. Other
User: The owner of a file belongs to this class
Group: The members of the file’s group belong to this class. A group is a collection of users. The main
purpose of the groups is to define a set of privileges like read, write, or execute permission for a given
resource that can be shared among the users within the group.
Other: Any users that are not part of the user or group classes belong to this class.
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
Linux Command.pptx
chown
The chown command changes ownership of files and directories in a filesystem.
To Change User ownership :
To change user ownership we will use
chown username file1.txt
To reach to root
Create new user
To check list of user using compgen -u
Changing the user
Chown username filename
To Change group ownership In our case I am using group1 as a
group in the system. To change ownership we will use
chown :group1 file1.txt

More Related Content

PPT
Linux command ppt
PPT
Linux basic commands
PDF
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
PPTX
XXE - XML External Entity Attack
PDF
File System Hierarchy
PPTX
Find and locate
PPT
Unix/Linux Basic Commands and Shell Script
PPTX
Unix
Linux command ppt
Linux basic commands
Linux Tutorial For Beginners | Linux Administration Tutorial | Linux Commands...
XXE - XML External Entity Attack
File System Hierarchy
Find and locate
Unix/Linux Basic Commands and Shell Script
Unix

What's hot (20)

PPT
Linux presentation
PDF
Unix / Linux Command Reference
PPT
Basic 50 linus command
PPT
Shell Scripting
PDF
Linux system admin
PDF
Shell scripting
PPTX
Windows Forensic 101
PPTX
Presentation on samba server
PDF
Linux Basic Commands
PDF
SANS Digital Forensics and Incident Response Poster 2012
PDF
Linux basic commands with examples
PDF
PowerDNS-Admin vs DNS-UI
ODP
An Introduction to Linux
PDF
Course 102: Lecture 14: Users and Permissions
PPTX
Understanding das-nas-san
PPTX
Linux basic commands
PDF
Domino Tech School - Upgrading to Notes/Domino V10: Best Practices
PPTX
Basic commands of linux
PPTX
NTFS vs FAT
PPT
Storage Management in Linux OS.ppt
Linux presentation
Unix / Linux Command Reference
Basic 50 linus command
Shell Scripting
Linux system admin
Shell scripting
Windows Forensic 101
Presentation on samba server
Linux Basic Commands
SANS Digital Forensics and Incident Response Poster 2012
Linux basic commands with examples
PowerDNS-Admin vs DNS-UI
An Introduction to Linux
Course 102: Lecture 14: Users and Permissions
Understanding das-nas-san
Linux basic commands
Domino Tech School - Upgrading to Notes/Domino V10: Best Practices
Basic commands of linux
NTFS vs FAT
Storage Management in Linux OS.ppt
Ad

Similar to Linux Command.pptx (20)

PPTX
various shell commands in unix operating system.pptx
PPTX
Basic Linux Commands and implementation with Examples
PPTX
Basic Linux Commands with syntax and functions
PPT
Linux commands
PPTX
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
PDF
linux commands.pdf
PDF
Linux_Commands.pdf
PDF
LinuxCommands (1).pdf
PPTX
Linux System commands Essentialsand Basics.pptx
DOCX
Chapter 4 Linux Basic Commands
PDF
Command Line Tools
PPT
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
PDF
PPT
linux-lecture4.ppt
PPTX
Code tacoma command_line
PDF
Basic linux commands
PPT
Linux commands
PDF
UNIX Command Cheat Sheets
PPT
Linux commands and file structure
PPTX
various shell commands in unix operating system.pptx
Basic Linux Commands and implementation with Examples
Basic Linux Commands with syntax and functions
Linux commands
TERMINAL COMMANDS IN LINUX TERMINAL USED TO INTERACT WITH SYSTEM
linux commands.pdf
Linux_Commands.pdf
LinuxCommands (1).pdf
Linux System commands Essentialsand Basics.pptx
Chapter 4 Linux Basic Commands
Command Line Tools
BITS: Introduction to Linux - Text manipulation tools for bioinformatics
linux-lecture4.ppt
Code tacoma command_line
Basic linux commands
Linux commands
UNIX Command Cheat Sheets
Linux commands and file structure
Ad

Recently uploaded (20)

PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPT
Quality review (1)_presentation of this 21
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
Global journeys: estimating international migration
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Database Infoormation System (DBIS).pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PDF
Introduction to Business Data Analytics.
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PDF
Foundation of Data Science unit number two notes
PDF
Mega Projects Data Mega Projects Data
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
.pdf is not working space design for the following data for the following dat...
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
oil_refinery_comprehensive_20250804084928 (1).pptx
Quality review (1)_presentation of this 21
IB Computer Science - Internal Assessment.pptx
Global journeys: estimating international migration
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Database Infoormation System (DBIS).pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Introduction to Business Data Analytics.
Miokarditis (Inflamasi pada Otot Jantung)
Galatica Smart Energy Infrastructure Startup Pitch Deck
Business Acumen Training GuidePresentation.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Foundation of Data Science unit number two notes
Mega Projects Data Mega Projects Data
Clinical guidelines as a resource for EBP(1).pdf
IBA_Chapter_11_Slides_Final_Accessible.pptx
.pdf is not working space design for the following data for the following dat...
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...

Linux Command.pptx

  • 2. LINUX COMMAND man: man command in Linux is used to display the user manual of any command that we can run on the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.
  • 4. pwd : Print Work Directory pwd stands for Print Working Directory. It prints the path of the working directory, starting from the root.
  • 5. To check the version of pwd Command : /bin/pwd --version
  • 6. cal command This command display the calendar of current month.
  • 8. Command: cal -m1 , cal -m2 , cal -m3 ...
  • 9. Command: cal -y year / cal -y 2020
  • 10. date Command : date Displays current time and date.
  • 11. whoami Command : whoami This command reveals the user who is currently logged in.
  • 12. whatis Command : whatis ls / whatis date This command gives a one line description about the command. It can be used as a quick reference for any command.
  • 13. w Command : w The w command lists the currently logged in users.
  • 14. id Command: id / id (root) by passing username as argument This command prints user and groups (UID and GID) of the current user.
  • 15. UID : User Identifier A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to determine which system resources the user can access. ● UID 0 (zero) is reserved for the root. ● UIDs 1–99 are reserved for other predefined accounts. ● UID 100–999 are reserved by system for administrative and system accounts/groups. ● UID 1000–10000 are occupied by applications account. ● UID 10000+ are used for user accounts.
  • 16. GID : Group Id Groups in Linux are defined by GIDs (group IDs). ● GID 0 (zero) is reserved for the root group. ● GID 1–99 are reserved for the system and application use. ● GID 100+ allocated for the user’s group.
  • 17. clear This command clears the screen Command : clear Shortcut : ctrl+L
  • 18. ps The ps command lists running processes. Using ps without any options causes it to list the processes running in the current shell. Command : ps
  • 19. history The history command lists the commands you have previously issued on the command line. You can repeat any of the commands from your history by typing an exclamation point ! and the number of the command from the history list Command : history
  • 20. mkdir The mkdir command allows you to create new directories in the filesystem. You must provide the name of the new directory to mkdir. If the new directory is not going to be within the current directory, you must provide the path to the new directory. Command : mkdir os / mkdir os cpp ds
  • 22. Linux version Uname to check the version of linux.
  • 23. -v 0r --verbose It displays a message for every directory created. Command: mkdir -v 1 2 3
  • 24. -p A flag which enables the command to create parent directories as necessary. If the directories exist, no error is specified. Command: mkdir -p dss/ds/d
  • 25. To create files Create a file with touch command We will use touch command with any extension to create file, this command will create an empty file test.txt in your current directory Command : touch file.txt
  • 26. Create a file with cat command cat command to create file, this command will create an empty file in your current directory, but you must add text in the file. Command: cat > testcat.txt This file has been created with cat command To save the file hit Ctrl + d and to check whether it is present in your directory or not Command : ls -l testcat.txt
  • 28. Create a file with echo command echo command to create file, this command will create a file in the current directory but you should add text in the line command. Command : echo "check echo" > testecho.txt To see the file,type command below. Command: ls -l testecho.txt
  • 30. Create a file with printf command We will use printf command to create file, this command will create a file printf.txt in your current directory as an example below, but you should add text in the line command. Command: printf "This file has been created with printf command" > printf.txt To see the file type command below. Command: ls -l printf.txt
  • 32. Create a file using nano To create a file using nano text editor, first install it, after that type command below and the text editor will be opened to adding text. Command : nano nano.txt Add the text below. This file has been created with nano text editor To save the file type Ctrl + x and type y, to see the file type command below. Command: ls -l nano.txt
  • 34. Create a file with vi editor To create a file using vi text editor, type command below and the text editor will open the file, but you can't add any text before converting it to insert mode by typing i character. Command: vi vi.txt Add the text below. This file has been created with vi text editor To save the file and exit hit Esc after that :wq, To see the file type command below. Command : ls -l vi.txt
  • 36. Create a file with vim text editor To create a file using vim text editor, type command below and the text editor will open the file, but you can't add any text before converting it to insert mode by typing i character. Command : vim vim.txt Add the text below. This file has been created with vim text editor To save the file and exit hit Esc after that :wq, to see the file type command below. Command : ls -l vim.txt
  • 37. How to remove a file To remove (or delete) a file in Linux from the command line, use either the rm (remove) or unlink command. To delete a single file, use the rm or unlink command followed by the file name: Command : unlink filename / rm filename
  • 39. To delete a file To delete multiple files at once, use the rm command followed by the file names separated by space. Command :rm filename1 filename2 filename3
  • 40. You can also use a wildcard (*) and regular expansions to match multiple files. For example, to remove all .pdf files in the current directory, use the following command: Command : rm *.pdf / rm *.txt
  • 41. ● Use the rm with the -i option to confirm each file before deleting it: Command : rm -i filename(s) ● To remove files without prompting even if the files are write-protected pass the -f (force) option to the rm command: Command : rm -f filename(s)
  • 43. Delete a empty directory use ‘-d‘ option in rm command to delete a empty directory. Command : rm -d appdata/
  • 44. You can also combine rm options. For example, to remove all .txt files in the current directory without a prompt in verbose mode, use the following command: Command: rm -fv *.txt
  • 45. How to remove directory In Linux, you can remove/delete directories with the rmdir and rm. rmdir is a command-line utility for deleting empty directories while with rm you can remove directories and their contents recursively.
  • 46. To remove an empty directory, use either rmdir or rm -d followed by the directory name: Command: rm -d dirname rmdir dirname
  • 47. -r‘ option in rm command will delete all the files and sub-directories recursively of the parent directory. rm -r dirname Delete the files and sub-directories interactively. Use ‘-ri‘ option in rm command to delete file and sub-directories interactively, Rm -ri dbstore To remove non-empty directories and all the files without being prompted, use rm with the -r (recursive) and -f options:rm -rf dirname
  • 48. To remove multiple directories at once, use the rm -r command followed by the directory names separated by space. Command : rm -r dirname1 dirname2 dirname3
  • 49. Delete large number files using rm command If your are trying to delete large number of files using rm command then you will get an error message ‘Argument list too long’ rm *.log
  • 50. Copy command Cp command is use to copy a file from source to destination Command :Cp target_file to source file
  • 51. Copy a file interactively If you wish to copy the files from one place to another interactively then use the “-i” option in cp command, interactive option only works if the destination directory already has the same file, example is shown below, Command : cp -i filename
  • 52. Copy a directory or folder (-r 0r -R) To copy a directory from one place to another use -r or -R option in cp command. Let’s assume we want to copy the home directory of linuxtechi user to “/mn/backup”, Command : cp -r /home/linuxtechi /mnt/backup/
  • 53. Do not overwrite the existing file while copying (-n) cp -n /etc/passwd /mnt/backup/
  • 54. Mv command move a file To move a file using the mv command pass the name of the file and then the new name for the file. In the following example the file foo.txt is renamed to bar.txt. mv foo.txt bar.txt
  • 55. Move a file into a directory To move a file into a directory using the mv command pass the name of the file and then the directory. In the following example the file foo.txt is moved into the directory bar. mv foo.txt bar
  • 56. How to move multiple file into a directory To move multiple files using the mv command pass the names of the files or a pattern followed by the destination. mv file1.txt file.2.txt file3.txt folder The following example is the same as above but uses pattern matching to move all files with a .txt extension. mv *.txt folder
  • 57. Move a directory To move a directory using the mv command pass the name of the directory to move followed by the destination. mv foo bar
  • 58. How to prompt before overwriting a file mv -i foo.txt bar.txt
  • 59. How to not overwrite an existing file To prevent an existing file from being overwritten pass the -n option mv -n foo.txt bar.txt
  • 60. How to take a backup of an existing file To take a backup of an existing file that will be overwritten as a result of the mv command pass the -b option. This will create a backup file with the tilde character appended to it. mv -b foo.txt bar.txt
  • 61. grep The grep utility searches for lines which contain a search pattern. When we looked at the alias command, we used grep to search through the output of another program, ps . The grep command can also search the contents of files. grep train *.txt
  • 62. gzip The gzip command compresses files. By default, it removes the original file and leaves you with the compressed version. To retain both the original and the compressed version, use the -k (keep) option. gzip -k core.c
  • 63. head head command gives you a listing of the first 10 lines of a file. If you want to see fewer or more lines, use the -n (number) option. In this example, we use head with its default of 10 lines. We then repeat the command asking for only five lines. Head -n 5 test.txt
  • 64. tail The tail command gives you a listing of the last 10 lines of a file. If you want to see fewer or more lines, use the -n (number) option. In this example, we use tail with its default of 10 lines. We then repeat the command asking for only five lines. tail core.c tail -n 5 core.c
  • 65. less The less command allows you to view files without opening an editor. It’s faster to use, and there’s no chance of you inadvertently modifying the file. With less you can scroll forward and backward through the file using the Up and Down Arrow keys, the PgUp and PgDn keys and the Home and End keys. Press the Q key to quit from less. To view a file provide its name to less as follows: less core.c
  • 66. ssh Use the ssh command to make a connection to a remote Linux computer and log into your account. To make a connection, you must provide your user name and the IP address or domain name of the remote computer. In this example, the user mary is logging into the computer at 192.168.4.23. ssh mary@192.168.4.23
  • 67. Cd command The cd command is used to change the current directory (i.e., the directory in which the user is currently working) in Linux
  • 68. Navigate to the Previous Directory To change back to the previous working directory, pass the dash (-) character as an argument to the cd command: cd -
  • 69. Navigate to the Home Directory To navigate to your home directory simply type cd. Another way to return directly to your home directory is to use the tilde (~) character, as shown below: cd ~
  • 70. Ls command Ls command shows the list of files and directories , where you won’t be able to view details like file types, size, modified date and time, permission and links etc. ls --version 1. A. ls -l shows file or directory, size, modified date and time, file or folder name and owner of file and its permission.
  • 71. ls > output.txt cat output.txt:
  • 73. 1. B. View Hidden Files: ls -a : contains the list of all the hidden file including “ .” and “. .” 1. C. List Files with Human Readable Format ls -lh : contains all the option which can be understood by non development person.
  • 74. 1. D. Sort Files by Files size ls -lS / ls -S -l: displays file size in order of bigger size first.
  • 75. ls -i : i over here is to check Inode Informations. An inode is a data structure that stores various information about a file in Linux, such as the access mode (read, write, execute permissions), ownership, file type, file size, group, number of links, etc. Each inode is identified by an integer number. An inode is assigned to a file when it is created.
  • 76. ls -R : You can list directories recursively using ls -R. Recursively means it will list all the directory with is all subdirectory in a tree format.
  • 77. ls -lt : Linux ls command with -t will list the files and directories by it’s modification date in ascending order, means the higher will be come first.
  • 78. ls ~ : command to list the contents in the user's home directory. ls -d */ command to list only directories: ls * command to list the contents of the directory with it's subdirectories ls -S (the S is uppercase) : command to list files or directories and sort by date or time in descending order (biggest to smallest). You can also add a -r flag to reverse the sorting order like so: ls -Sr
  • 79. ls -n: ls command with option -n will show the UID (User ID) and GID (Group ID) numbers of file and directory. A UID (user identifier) is a number assigned by Linux to each user on the system. This number is used to identify the user to the system and to determine which system resources the user can access. ● UID 0 (zero) is reserved for the root. ● UIDs 1–99 are reserved for other predefined accounts. ● UID 100–999 are reserved by system for administrative and system accounts/groups. ● UID 1000–10000 are occupied by applications account. ● UID 10000+ are used for user accounts.
  • 80. GID Groups in Linux are defined by GIDs (group IDs). ● GID 0 (zero) is reserved for the root group. ● GID 1–99 are reserved for the system and application use. ● GID 100+ allocated for the user’s group.
  • 81. ls -G If you want to list only Owner of the files and directories to which they are belongs and not groups then use Linux ls command with argument -G.
  • 82. There are three permissions groups: 1. Owner 2. Group 3. Other
  • 83. User: The owner of a file belongs to this class Group: The members of the file’s group belong to this class. A group is a collection of users. The main purpose of the groups is to define a set of privileges like read, write, or execute permission for a given resource that can be shared among the users within the group. Other: Any users that are not part of the user or group classes belong to this class.
  • 94. chown The chown command changes ownership of files and directories in a filesystem.
  • 95. To Change User ownership : To change user ownership we will use chown username file1.txt
  • 96. To reach to root
  • 98. To check list of user using compgen -u
  • 99. Changing the user Chown username filename
  • 100. To Change group ownership In our case I am using group1 as a group in the system. To change ownership we will use chown :group1 file1.txt