SlideShare uma empresa Scribd logo
1 de 100
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 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
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
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
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
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
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
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:
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.
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

Mais conteúdo relacionado

Semelhante a Linux Command.pptx

Semelhante a Linux Command.pptx (20)

50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Operating System Laboratory presentation .ppt
Operating System Laboratory presentation .pptOperating System Laboratory presentation .ppt
Operating System Laboratory presentation .ppt
 
Linux
LinuxLinux
Linux
 
Group13
Group13Group13
Group13
 
11 unix osx_commands
11 unix osx_commands11 unix osx_commands
11 unix osx_commands
 
Code tacoma command_line
Code tacoma command_lineCode tacoma command_line
Code tacoma command_line
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
40 basic linux command
40 basic linux command40 basic linux command
40 basic linux command
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 

Último

Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxMohammedJunaid861692
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlCall Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlkumarajju5765
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 

Último (20)

Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptxBPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
BPAC WITH UFSBI GENERAL PRESENTATION 18_05_2017-1.pptx
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girlCall Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
Call Girls 🫤 Dwarka ➡️ 9711199171 ➡️ Delhi 🫦 Two shot with one girl
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 

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
  • 21.
  • 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
  • 27.
  • 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
  • 29.
  • 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
  • 31.
  • 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
  • 33.
  • 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
  • 35.
  • 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
  • 38.
  • 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:
  • 72.
  • 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.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 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