SlideShare a Scribd company logo
Shell commands
Nagendra
Ls command
• List Files using ls with no option
• ls with no option list files and directories in bare format where we
won’t be able to view details like file types, size, modified date and
time, permission and links etc.
• List Files With option –l
• Here, ls -l (-l is character not one) shows file or directory, size,
modified date and time, file or folder name and owner of file and it’s
permission.
• View Hidden Files
• List all files including hidden file starting with ‘.‘.
• List Files with Human Readable Format with option -lh
• With combination of -lh option, shows sizes in human readable
format.
• List Files in Reverse Order
• The following command with ls -r option display files and directories
in reverse order.
• Shows version of ls command
• Check version of ls command.
• Show Help Page
• List help page of ls command with their option.
pwd command
• pwd‘ stands for ‘Print Working Directory‘. As the name states,
command ‘pwd‘ prints the current working directory or simply the
directory user is, at present. It prints the current directory name with
the complete path starting from root (/). This command is built in
shell command and is available on most of the shell – bash, Bourne
shell, ksh, zsh, etc.
• Basic syntax of pwd:
#pwd[option]
• If both ‘-L‘ and ‘-P‘ options are used, option ‘L‘ is taken into priority. If no option is
specified at the prompt, pwd will avoid all symlinks, i.e., take option ‘-P‘ into account.
• Note: A ‘pwd’ command is often used without options and never used with arguments.
Options Description
-L (logical) Use PWD from environment, even if it contains symbolic links
-P (physical) Avoid all symbolic links
–help Display this help and exit
–version Output version information and exit
various shell commands in unix operating system.pptx
tty
• tty is a place where the running command runs.
cat command
• Syntax
cat[option][file]…
• Display Contains of File
• In the below example, it will show contains of /etc/passwd file.
• View Contains of Multiple Files in terminal
• In below example, it will display contains of test and test1 file in
terminal.
• Create a File with Cat Command
• We will create a file called test2 file with below command.
• Awaits input from user, type desired text and press CTRL+D (hold
down Ctrl Key and type ‘d‘) to exit. The text will be written
in test2 file. You can see contains of file with following cat command.
• Use Cat Command with More & Less Options
• If file having large number of contains that won’t fit in output terminal and screen scrolls up
very fast, we can use parameters more and less with cat command as show above.
• Display Line Numbers in File
• With -n option you could see the line numbers of a file song.txt in the output terminal.
• Display Multiple Files at Once
• In the below example we have three files test, test1 and test2 and
able to view the contains of those file as shown above. We need to
separate each file with ; (semi colon).
• Use Standard Output with Redirection Operator
• We can redirect standard output of a file into a new file else existing file with
‘>‘ (greater than) symbol. Careful, existing contains of test1 will be
overwritten by contains of test file.
#cat test > test1
• Appending Standard Output with Redirection Operator
• Appends in existing file with ‘>>‘ (double greater than) symbol. Here,
contains of test file will be appended at the end of test1 file.
#cat test >> test1
• Redirecting Multiple Files Contain in a Single File
• This will create a file called test3 and all output will be redirected in a newly
created file.
#cat test test1 test2 > test3
who command
• who command is a tool print information about users who are
currently logged in. who command only see a real user who logged
in.
$who [options] [filename]
whoami command
• whoami command is used both in Unix Operating System and as well
as in Windows Operating System.
• It is basically the concatenation of the
strings “who”,”am”,”i” as whoami.
• It displays the username of the current user when this command is
invoked.
• It is similar as running the id command with the options -un.
rm command
• To run rm command, type rm followed by filename. Please
remember, that by default rm will not ask any confirmation.
• Remove a file
# rm xyz.log
• Remove multiple file with specific extension
• If you have multiple file with the same extension and you want to
delete them, you can use this syntax :
# rm *.log
• Remove a directory
• Removing directory is a little bit tricky. If you are sure that the directory is
empty, then we can use -d parameter to remove it.
# rm –d documents/
• But when the directory is not empty, you have to empty the directory first, or
you can remove them recursively. To remove recursively, use -r or -R parameter.
# rm –r documents/
• Add interactive confirmation before deleting
• If you feel more comfortable to have interactive confirmation, you can use -
i parameter with rm command. Here’s a sample of deleting directory recursively
with interactive confirmation.
# rm –ri documents/
mkdir command
• Running mkdir without any parameter will create directory under the current
directory
• Create multiple directories
#mkdir aa bb cc
• Add directory include its sub-directory
• When you want to created a include its sub-directory, you will need to use -
p parameter.
#mkdir –p aa/bb
• Set access privilege
• Using -m parameter, we can also set the access privilege for the new directory on-
the-fly.
rmdir command
• rmdir [OPTION] {directory-name}
• To delete directory called foo
#rmdir foo
• Remove DIRECTORY and its ancestors
• For example remove directory structure sales/99/march
#rmdir –p sales/99/march
touch command
• The touch command is a standard command used in UNIX/Linux operating
system which is used to create, change and modify timestamps of a file.
#touch filename
• The file which is created can be viewed by ls command and to get more
details about the file you can use long listing command ll or ls -l command .
• Touch command to create multiple files: Touch command can be used to
create the multiple numbers of files at the same time. These files would be
empty while creation.
#touch file1 file2 file3
cd command
• Change from current directory to /usr/local.
• Change from current directory to /usr/local/lib using absolute path.
• Change from current working directory to /usr/local/lib using relative
path.
• Move one directory back from where you are now.
• Change Current directory to parent directory.
• Move to users home directory from anywhere.
cal command- display a calendar
• A single parameter specifies the 4 digit year (1 - 9999) to be
displayed. Two parameters denote the Month (1 - 12) and Year (1 -
9999). If arguments are not specified, the current month is
displayed. A year starts on 01 Jan.
various shell commands in unix operating system.pptx
cat command- Append Data To a File
• Create another text file called bar.txt
$ echo 'For desktop usage I prefer Apple OS X unix operating systems.' > bar.txt
• Display both files on the screen, enter:
$ cat foo.txt
$ cat bar.txt
• To append a contains of bar.txt to to foo.txt, enter:
$ cat bar.txt >> foo.txt
$ cat foo.txt
• To append a ‘Use unix or die’ text to foo.txt file, enter:
$ echo 'Use unix or die' >> foo.txt
$ cat foo.txt
various shell commands in unix operating system.pptx
cat command- concatenation
# sample.txt
This is a sample text file
# sample1.txt
This is a another sample text file
To concatenate two files.
$ cat sample.txt sample1.txt > sample2.txt
$ cat sample2.txt
This is a sample text file
This is a another sample text file
mv command
• mv stands for move. mv is used to move one or more files or directories from one
place to another in a file system like UNIX. It has two distinct functions:
(i) It renames a file or folder.
(ii) It moves a group of files to a different directory.
• No additional space is consumed on a disk during renaming. This command normally
works silently means no prompt for confirmation.
• Syntax:
mv [Option] source destination
$ mv geek.txt b.txt
• -i (Interactive): Like in cp, the -i option makes the command ask the user for
confirmation before moving a file that would overwrite an existing file, you have to press
y for confirm moving, any other key leaves the file as it is.
$ mv -i geek.txt b.txt mv: overwrite 'b.txt’? Y
• -b(backup): With this option, it is easier to take a backup of an existing file that will be
overwritten as a result of the mv command. This will create a backup file with the tilde
character(~) appended to it.
$ mv -b geek.txt b.txt
• –version: This option is used to display the version of mv which is currently running on
your system.
$ mv --version
cp command- copy one or more files to another location.
• Copy sample.txt to sample.bak
$ cat sample.txt
This is a sample file
$ cp sample.txt sample.bak
$ cat sample.bak
This is a sample file
• Copy sample directory to home directory
$ cp -f /user/sample/* >
man command
• 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.
• Syntax :
$man [OPTION]... [COMMAND NAME]...
eg.
$ man printf
various shell commands in unix operating system.pptx
• $ man -f ls
chmod command
• In Unix-like operating systems, the chmod command is used to change the access
mode of a file.
• The name is an abbreviation of change mode.
• The references are used to distinguish the users to whom the permissions apply i.e.
they are list of letters that specifies whom to give permissions. The references are
represented by one or more of the following letters:
• Reference Class Description
u owner file's owner
g group users who are members of the file's group
o others users who are neither the file's owner nor members of the
file's group
a all All three of the above, same as ugo
• The operator is used to specify how the modes of a file should be adjusted. The
following operators are accepted:
• Operator Description
+ Adds the specified modes to the specified classes
- Removes the specified modes from the specified classes
= The modes specified are to be made the exact modes for the
specified classes
• The modes indicate which permissions are to be granted or removed from the specified
classes. There are three basic modes which correspond to the basic permissions:
r Permission to read the file.
w Permission to write (or delete) the file.
x Permission to execute the file, or, in the case of a directory, search it.
• change the assgn1_client.c permission so that the owner cannot
write(w) in the file but can only read it.
BEFORE: -rw-rw-r-- mik mik assgn1_client.c
COMMAND: chmod u=r assgn1_client.c
AFTER: -r--rw-r-- mik mik assgn1_client.c
grep command
• The grep filter searches a file for a particular pattern of characters,
and displays all lines that contain that pattern. The pattern that is
searched in the file is referred to as the regular expression (grep
stands for globally search for regular expression and print out).
Syntax:
# grep [options] pattern [files]
various shell commands in unix operating system.pptx
$cat > geekfile.txt
unix is great os. unix is opensource. unix is free os.
learn operating system.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful.
Case insensitive search : The -i option enables to search for a string case insensitively in the give
file. It matches the words like “UNIX”, “Unix”, “unix”.
$grep -i "UNix" geekfile.txt
Output:
unix is great os. unix is opensource. unix is free os.
Unix linux which one you choose.
uNix is easy to learn.unix is a multiuser os.Learn unix .unix is
• Displaying the count of number of matches : We can find the number of lines that matches the
given string/pattern
$grep -c "unix" geekfile.txt
Output:
2
• Display the file names that matches the pattern : We can just display the files that contains the given
string/pattern.
$grep -l "unix" *
or
$grep -l "unix" f1.txt f2.txt f3.xt f4.txt
Output:
geekfile.txt
tput command
• tput utility uses the terminfo database to make the values of terminal-dependent capabilities and
information available to the shell, to initialize or reset the terminal, or return the long name of the
requested terminal type.
• Set the Cursor Position using tput cup
$ tput cup 2 3
• Clear the Screen Using tput clear
$ tput clear
• Get the Number of Columns and Lines of a Terminal
$ tput cols
• displays number of lines of your terminal screen
$ tput lines
• Change the Terminal Background Color using tput setb
$ tput setb 4
bc command
• bc command is used for command line calculator. It is similar to basic calculator by using which we can
do basic mathematical calculations.
• Arithmetic operations are the most basic in any kind of programming language. Linux or Unix operating
system provides the bc command and expr command for doing arithmetic calculations. These
commands are used in bash or shell script also for evaluating arithmetic expressions.
Syntax:
bc [ -hlwsqv ] [long-options] [ file ... ]
Options:
-h, {- -help } : Print the usage and exit
-i, {- -interactive } : Force interactive mode
-l, {- -mathlib } : Define the standard math library
-w, {- -warn } : Give warnings for extensions to POSIX bc
-s, {- -standard } : Process exactly the POSIX bc language
-q, {- -quiet } : Do not print the normal GNU bc welcome
-v, {- -version } : Print the version number and copyright and quit
• The bc command supports the following features:
• Arithmetic operators
• Increment or Decrement operators
• Assignment operators
• Comparison or Relational operators
• Logical or Boolean operators
• Math functions
• Conditional statements
• Iterative statements
$ echo "12+5" | bc
Output
17
$ echo "10^2" | bc
Output
100
$ echo "var=10;var" | bc
Output
10
Assign 10 to the variable and print the value on the terminal.
$ echo "var=10;var^=2;var" | bc
Output
100
Squares the value of the variable and print the value on the terminal.
Ad

More Related Content

Similar to various shell commands in unix operating system.pptx (20)

Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
Rajesh Kumar
 
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptxos lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
AdityaGupta221734
 
Linux ppt
Linux pptLinux ppt
Linux ppt
Sanmuga Nathan
 
Linux
LinuxLinux
Linux
RittikaBaksi
 
Unix cmc
Unix cmcUnix cmc
Unix cmc
Oussama BENNANI
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
Vinoth Sn
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
Basic Linux Administration - 3.pptxon server
Basic Linux Administration - 3.pptxon serverBasic Linux Administration - 3.pptxon server
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1
sdiviney
 
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.pptmanaging-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.ppt
submarinoaguadulce1
 
managing-the-linux-file-system________________________
managing-the-linux-file-system________________________managing-the-linux-file-system________________________
managing-the-linux-file-system________________________
saurabhbquest
 
linux-file-system01.ppt
linux-file-system01.pptlinux-file-system01.ppt
linux-file-system01.ppt
MeesanRaza
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
Chander Pandey
 
Linux Basics.pptx
Linux Basics.pptxLinux Basics.pptx
Linux Basics.pptx
RanjitKumarPanda5
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
QUONTRASOLUTIONS
 
redhat_by_Cbitss.ppt
redhat_by_Cbitss.pptredhat_by_Cbitss.ppt
redhat_by_Cbitss.ppt
VikrantSChohaan
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
Rajesh Kumar
 
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptxos lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
os lab commanaaaaaaaaaaaaaaaaaaaaaads.pptx
AdityaGupta221734
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
Vinoth Sn
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
Basic Linux Administration - 3.pptxon server
Basic Linux Administration - 3.pptxon serverBasic Linux Administration - 3.pptxon server
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1
sdiviney
 
managing-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.pptmanaging-the-linux-file-system_suse_.ppt
managing-the-linux-file-system_suse_.ppt
submarinoaguadulce1
 
managing-the-linux-file-system________________________
managing-the-linux-file-system________________________managing-the-linux-file-system________________________
managing-the-linux-file-system________________________
saurabhbquest
 
linux-file-system01.ppt
linux-file-system01.pptlinux-file-system01.ppt
linux-file-system01.ppt
MeesanRaza
 
PowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programmingPowerPoint_merge.ppt on unix programming
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
southees
 
Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01Linuxtraining 130710022121-phpapp01
Linuxtraining 130710022121-phpapp01
Chander Pandey
 
Linux operating system by Quontra Solutions
Linux operating system by Quontra SolutionsLinux operating system by Quontra Solutions
Linux operating system by Quontra Solutions
QUONTRASOLUTIONS
 
Commands and shell programming (3)
Commands and shell programming (3)Commands and shell programming (3)
Commands and shell programming (3)
christ university
 
OS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topicsOS-Module 2 Linux Programming Important topics
OS-Module 2 Linux Programming Important topics
JithinS34
 

Recently uploaded (20)

How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Building a research repository that works by Clare Cady
Building a research repository that works by Clare CadyBuilding a research repository that works by Clare Cady
Building a research repository that works by Clare Cady
UXPA Boston
 
React Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for SuccessReact Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for Success
Amelia Swank
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Preeti Jha
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdfComputer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
fizarcse
 
Best 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat PlatformsBest 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat Platforms
Soulmaite
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
How Top Companies Benefit from Outsourcing
How Top Companies Benefit from OutsourcingHow Top Companies Benefit from Outsourcing
How Top Companies Benefit from Outsourcing
Nascenture
 
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
Multi-Agent AI Systems: Architectures & Communication (MCP and A2A)
HusseinMalikMammadli
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Building a research repository that works by Clare Cady
Building a research repository that works by Clare CadyBuilding a research repository that works by Clare Cady
Building a research repository that works by Clare Cady
UXPA Boston
 
React Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for SuccessReact Native for Business Solutions: Building Scalable Apps for Success
React Native for Business Solutions: Building Scalable Apps for Success
Amelia Swank
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
Slack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teamsSlack like a pro: strategies for 10x engineering teams
Slack like a pro: strategies for 10x engineering teams
Nacho Cougil
 
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Middle East and Africa Cybersecurity Market Trends and Growth Analysis
Preeti Jha
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)Design pattern talk by Kaya Weers - 2025 (v2)
Design pattern talk by Kaya Weers - 2025 (v2)
Kaya Weers
 
Cybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft CertificateCybersecurity Tools and Technologies - Microsoft Certificate
Cybersecurity Tools and Technologies - Microsoft Certificate
VICTOR MAESTRE RAMIREZ
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdfComputer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
fizarcse
 
Best 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat PlatformsBest 10 Free AI Character Chat Platforms
Best 10 Free AI Character Chat Platforms
Soulmaite
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Who's choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
Ad

various shell commands in unix operating system.pptx

  • 2. Ls command • List Files using ls with no option • ls with no option list files and directories in bare format where we won’t be able to view details like file types, size, modified date and time, permission and links etc.
  • 3. • List Files With option –l • Here, ls -l (-l is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and it’s permission.
  • 4. • View Hidden Files • List all files including hidden file starting with ‘.‘.
  • 5. • List Files with Human Readable Format with option -lh • With combination of -lh option, shows sizes in human readable format.
  • 6. • List Files in Reverse Order • The following command with ls -r option display files and directories in reverse order. • Shows version of ls command • Check version of ls command.
  • 7. • Show Help Page • List help page of ls command with their option.
  • 8. pwd command • pwd‘ stands for ‘Print Working Directory‘. As the name states, command ‘pwd‘ prints the current working directory or simply the directory user is, at present. It prints the current directory name with the complete path starting from root (/). This command is built in shell command and is available on most of the shell – bash, Bourne shell, ksh, zsh, etc. • Basic syntax of pwd: #pwd[option]
  • 9. • If both ‘-L‘ and ‘-P‘ options are used, option ‘L‘ is taken into priority. If no option is specified at the prompt, pwd will avoid all symlinks, i.e., take option ‘-P‘ into account. • Note: A ‘pwd’ command is often used without options and never used with arguments. Options Description -L (logical) Use PWD from environment, even if it contains symbolic links -P (physical) Avoid all symbolic links –help Display this help and exit –version Output version information and exit
  • 11. tty • tty is a place where the running command runs.
  • 12. cat command • Syntax cat[option][file]… • Display Contains of File • In the below example, it will show contains of /etc/passwd file.
  • 13. • View Contains of Multiple Files in terminal • In below example, it will display contains of test and test1 file in terminal.
  • 14. • Create a File with Cat Command • We will create a file called test2 file with below command. • Awaits input from user, type desired text and press CTRL+D (hold down Ctrl Key and type ‘d‘) to exit. The text will be written in test2 file. You can see contains of file with following cat command.
  • 15. • Use Cat Command with More & Less Options • If file having large number of contains that won’t fit in output terminal and screen scrolls up very fast, we can use parameters more and less with cat command as show above. • Display Line Numbers in File • With -n option you could see the line numbers of a file song.txt in the output terminal.
  • 16. • Display Multiple Files at Once • In the below example we have three files test, test1 and test2 and able to view the contains of those file as shown above. We need to separate each file with ; (semi colon).
  • 17. • Use Standard Output with Redirection Operator • We can redirect standard output of a file into a new file else existing file with ‘>‘ (greater than) symbol. Careful, existing contains of test1 will be overwritten by contains of test file. #cat test > test1 • Appending Standard Output with Redirection Operator • Appends in existing file with ‘>>‘ (double greater than) symbol. Here, contains of test file will be appended at the end of test1 file. #cat test >> test1 • Redirecting Multiple Files Contain in a Single File • This will create a file called test3 and all output will be redirected in a newly created file. #cat test test1 test2 > test3
  • 18. who command • who command is a tool print information about users who are currently logged in. who command only see a real user who logged in. $who [options] [filename]
  • 19. whoami command • whoami command is used both in Unix Operating System and as well as in Windows Operating System. • It is basically the concatenation of the strings “who”,”am”,”i” as whoami. • It displays the username of the current user when this command is invoked. • It is similar as running the id command with the options -un.
  • 20. rm command • To run rm command, type rm followed by filename. Please remember, that by default rm will not ask any confirmation. • Remove a file # rm xyz.log • Remove multiple file with specific extension • If you have multiple file with the same extension and you want to delete them, you can use this syntax : # rm *.log
  • 21. • Remove a directory • Removing directory is a little bit tricky. If you are sure that the directory is empty, then we can use -d parameter to remove it. # rm –d documents/ • But when the directory is not empty, you have to empty the directory first, or you can remove them recursively. To remove recursively, use -r or -R parameter. # rm –r documents/ • Add interactive confirmation before deleting • If you feel more comfortable to have interactive confirmation, you can use - i parameter with rm command. Here’s a sample of deleting directory recursively with interactive confirmation. # rm –ri documents/
  • 22. mkdir command • Running mkdir without any parameter will create directory under the current directory • Create multiple directories #mkdir aa bb cc • Add directory include its sub-directory • When you want to created a include its sub-directory, you will need to use - p parameter. #mkdir –p aa/bb • Set access privilege • Using -m parameter, we can also set the access privilege for the new directory on- the-fly.
  • 23. rmdir command • rmdir [OPTION] {directory-name} • To delete directory called foo #rmdir foo • Remove DIRECTORY and its ancestors • For example remove directory structure sales/99/march #rmdir –p sales/99/march
  • 24. touch command • The touch command is a standard command used in UNIX/Linux operating system which is used to create, change and modify timestamps of a file. #touch filename • The file which is created can be viewed by ls command and to get more details about the file you can use long listing command ll or ls -l command . • Touch command to create multiple files: Touch command can be used to create the multiple numbers of files at the same time. These files would be empty while creation. #touch file1 file2 file3
  • 25. cd command • Change from current directory to /usr/local. • Change from current directory to /usr/local/lib using absolute path.
  • 26. • Change from current working directory to /usr/local/lib using relative path. • Move one directory back from where you are now.
  • 27. • Change Current directory to parent directory. • Move to users home directory from anywhere.
  • 28. cal command- display a calendar • A single parameter specifies the 4 digit year (1 - 9999) to be displayed. Two parameters denote the Month (1 - 12) and Year (1 - 9999). If arguments are not specified, the current month is displayed. A year starts on 01 Jan.
  • 30. cat command- Append Data To a File
  • 31. • Create another text file called bar.txt $ echo 'For desktop usage I prefer Apple OS X unix operating systems.' > bar.txt • Display both files on the screen, enter: $ cat foo.txt $ cat bar.txt • To append a contains of bar.txt to to foo.txt, enter: $ cat bar.txt >> foo.txt $ cat foo.txt • To append a ‘Use unix or die’ text to foo.txt file, enter: $ echo 'Use unix or die' >> foo.txt $ cat foo.txt
  • 33. cat command- concatenation # sample.txt This is a sample text file # sample1.txt This is a another sample text file To concatenate two files. $ cat sample.txt sample1.txt > sample2.txt $ cat sample2.txt This is a sample text file This is a another sample text file
  • 34. mv command • mv stands for move. mv is used to move one or more files or directories from one place to another in a file system like UNIX. It has two distinct functions: (i) It renames a file or folder. (ii) It moves a group of files to a different directory. • No additional space is consumed on a disk during renaming. This command normally works silently means no prompt for confirmation. • Syntax: mv [Option] source destination $ mv geek.txt b.txt
  • 35. • -i (Interactive): Like in cp, the -i option makes the command ask the user for confirmation before moving a file that would overwrite an existing file, you have to press y for confirm moving, any other key leaves the file as it is. $ mv -i geek.txt b.txt mv: overwrite 'b.txt’? Y • -b(backup): With this option, it is easier to take a backup of an existing file that will be overwritten as a result of the mv command. This will create a backup file with the tilde character(~) appended to it. $ mv -b geek.txt b.txt • –version: This option is used to display the version of mv which is currently running on your system. $ mv --version
  • 36. cp command- copy one or more files to another location. • Copy sample.txt to sample.bak $ cat sample.txt This is a sample file $ cp sample.txt sample.bak $ cat sample.bak This is a sample file • Copy sample directory to home directory $ cp -f /user/sample/* >
  • 37. man command • 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. • Syntax : $man [OPTION]... [COMMAND NAME]... eg. $ man printf
  • 39. • $ man -f ls
  • 40. chmod command • In Unix-like operating systems, the chmod command is used to change the access mode of a file. • The name is an abbreviation of change mode. • The references are used to distinguish the users to whom the permissions apply i.e. they are list of letters that specifies whom to give permissions. The references are represented by one or more of the following letters: • Reference Class Description u owner file's owner g group users who are members of the file's group o others users who are neither the file's owner nor members of the file's group a all All three of the above, same as ugo
  • 41. • The operator is used to specify how the modes of a file should be adjusted. The following operators are accepted: • Operator Description + Adds the specified modes to the specified classes - Removes the specified modes from the specified classes = The modes specified are to be made the exact modes for the specified classes • The modes indicate which permissions are to be granted or removed from the specified classes. There are three basic modes which correspond to the basic permissions: r Permission to read the file. w Permission to write (or delete) the file. x Permission to execute the file, or, in the case of a directory, search it.
  • 42. • change the assgn1_client.c permission so that the owner cannot write(w) in the file but can only read it. BEFORE: -rw-rw-r-- mik mik assgn1_client.c COMMAND: chmod u=r assgn1_client.c AFTER: -r--rw-r-- mik mik assgn1_client.c
  • 43. grep command • The grep filter searches a file for a particular pattern of characters, and displays all lines that contain that pattern. The pattern that is searched in the file is referred to as the regular expression (grep stands for globally search for regular expression and print out). Syntax: # grep [options] pattern [files]
  • 45. $cat > geekfile.txt unix is great os. unix is opensource. unix is free os. learn operating system. Unix linux which one you choose. uNix is easy to learn.unix is a multiuser os.Learn unix .unix is a powerful. Case insensitive search : The -i option enables to search for a string case insensitively in the give file. It matches the words like “UNIX”, “Unix”, “unix”. $grep -i "UNix" geekfile.txt Output: unix is great os. unix is opensource. unix is free os. Unix linux which one you choose. uNix is easy to learn.unix is a multiuser os.Learn unix .unix is
  • 46. • Displaying the count of number of matches : We can find the number of lines that matches the given string/pattern $grep -c "unix" geekfile.txt Output: 2 • Display the file names that matches the pattern : We can just display the files that contains the given string/pattern. $grep -l "unix" * or $grep -l "unix" f1.txt f2.txt f3.xt f4.txt Output: geekfile.txt
  • 47. tput command • tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell, to initialize or reset the terminal, or return the long name of the requested terminal type. • Set the Cursor Position using tput cup $ tput cup 2 3 • Clear the Screen Using tput clear $ tput clear • Get the Number of Columns and Lines of a Terminal $ tput cols • displays number of lines of your terminal screen $ tput lines • Change the Terminal Background Color using tput setb $ tput setb 4
  • 48. bc command • bc command is used for command line calculator. It is similar to basic calculator by using which we can do basic mathematical calculations. • Arithmetic operations are the most basic in any kind of programming language. Linux or Unix operating system provides the bc command and expr command for doing arithmetic calculations. These commands are used in bash or shell script also for evaluating arithmetic expressions. Syntax: bc [ -hlwsqv ] [long-options] [ file ... ] Options: -h, {- -help } : Print the usage and exit -i, {- -interactive } : Force interactive mode -l, {- -mathlib } : Define the standard math library -w, {- -warn } : Give warnings for extensions to POSIX bc -s, {- -standard } : Process exactly the POSIX bc language -q, {- -quiet } : Do not print the normal GNU bc welcome -v, {- -version } : Print the version number and copyright and quit
  • 49. • The bc command supports the following features: • Arithmetic operators • Increment or Decrement operators • Assignment operators • Comparison or Relational operators • Logical or Boolean operators • Math functions • Conditional statements • Iterative statements
  • 50. $ echo "12+5" | bc Output 17 $ echo "10^2" | bc Output 100 $ echo "var=10;var" | bc Output 10 Assign 10 to the variable and print the value on the terminal. $ echo "var=10;var^=2;var" | bc Output 100 Squares the value of the variable and print the value on the terminal.