SlideShare a Scribd company logo
1 of 17
Introducing theIntroducing the
Command LineCommand Line
CMSC 121 Introduction to UNIXCMSC 121 Introduction to UNIX
Much of the material in these slides was taken fromMuch of the material in these slides was taken from
Dan Hood’s CMSC 121 Lecture Notes.Dan Hood’s CMSC 121 Lecture Notes.
Format of UNIX CommandsFormat of UNIX Commands
 UNIX commands can be very simple one word commands, or they can take aUNIX commands can be very simple one word commands, or they can take a
number of additional arguments (parameters) as part of the command. Innumber of additional arguments (parameters) as part of the command. In
general, a UNIX command has the following form:general, a UNIX command has the following form:
command options(s) filename(s)command options(s) filename(s)
 TheThe commandcommand is the name of the utility or program that we are going tois the name of the utility or program that we are going to
execute.execute.
 TheThe optionsoptions modify the way the command works. It is typical for these optionsmodify the way the command works. It is typical for these options
to have be a hyphen followed by a single character, such asto have be a hyphen followed by a single character, such as -a-a. It is also a. It is also a
common convention under Linux to have options that are in the form of 2common convention under Linux to have options that are in the form of 2
hyphens followed by a word or hyphenated words, such ashyphens followed by a word or hyphenated words, such as --color--color oror
--pretty-print--pretty-print..
 TheThe filenamefilename is the last argument for a lot of UNIX commands. It is simply theis the last argument for a lot of UNIX commands. It is simply the
file or files that you want the command to work on. Not all commands workfile or files that you want the command to work on. Not all commands work
on files, such ason files, such as sshssh, which takes the name of a host as its argument., which takes the name of a host as its argument.
Common UNIX ConventionsCommon UNIX Conventions
 In UNIX, the command is almost alwaysIn UNIX, the command is almost always
entered in allentered in all lowercaselowercase characters.characters.
 Typically any options come before filenames.Typically any options come before filenames.
 Many times, individual options may need a wordMany times, individual options may need a word
after them to designate some additional meaningafter them to designate some additional meaning
to the command.to the command.
Familiar Commands:Familiar Commands:
scp (Secure CoPy)scp (Secure CoPy)
 TheThe scpscp command is a way to copy files backcommand is a way to copy files back
and forth between multiple computers.and forth between multiple computers.
 Formats for this command:Formats for this command:
 scp path/local_name username@hostname:path/remote_namescp path/local_name username@hostname:path/remote_name
 scp username@hostname:path/remote_name path/local_namescp username@hostname:path/remote_name path/local_name
 Demo with renaming and copying files.Demo with renaming and copying files.
Familiar Commands:Familiar Commands:
ssh (Secure SHell)ssh (Secure SHell)
 TheThe sshssh command is a way to securely connect to a remote computer.command is a way to securely connect to a remote computer.
 Formats for this command:Formats for this command:
 ssh hostnamessh hostname
 ssh username@hostnamessh username@hostname
 ssh hostname -l usernamessh hostname -l username
 If you do not specify the username, it will assume that you want to connectIf you do not specify the username, it will assume that you want to connect
with the same username that you have on this local computer.with the same username that you have on this local computer.
 Since you have a single username for all computers on the OIT network, youSince you have a single username for all computers on the OIT network, you
don’t need to explicitly enter a username.don’t need to explicitly enter a username.
 But you can give a username, and will need to if your local username is differentBut you can give a username, and will need to if your local username is different
that your GL username. This might be the case if you are logging on from homethat your GL username. This might be the case if you are logging on from home
and set up your username to be different from what it is on GL.and set up your username to be different from what it is on GL.
 Demo with connecting with different usernames.Demo with connecting with different usernames.
Familiar Commands:Familiar Commands:
ssh (Secure SHell)ssh (Secure SHell)
 You can save a couple of keystrokes if you are on oneYou can save a couple of keystrokes if you are on one
of the Linux PCs in the labs:of the Linux PCs in the labs:
 You really only need to specify enough of a hostname as youYou really only need to specify enough of a hostname as you
may need.may need.
 Linux will automatically attempt to fill out the hostname withLinux will automatically attempt to fill out the hostname with
“umbc.edu” for you.“umbc.edu” for you.
 So if you want to log onto the lightest loaded linux server onSo if you want to log onto the lightest loaded linux server on
gl, you only need to issue the following command...gl, you only need to issue the following command...
ssh linux.glssh linux.gl
 Or, if you don't care the flavor of UNIX, you can simplyOr, if you don't care the flavor of UNIX, you can simply
type...type...
ssh glssh gl
Familiar Commands:Familiar Commands:
passwd (change PASSWorD)passwd (change PASSWorD)
 TheThe passwdpasswd command changes your UNIXcommand changes your UNIX
password.password.
 This command is an example of a “noThis command is an example of a “no
argument” command. Thus, the format of thisargument” command. Thus, the format of this
command is just the command name itself.command is just the command name itself.
passwdpasswd
 passwd is an interactive command, as once wepasswd is an interactive command, as once we
have typed it, we need to interact with it.have typed it, we need to interact with it.
Familiar Commands:Familiar Commands:
quota (account QUOTA)quota (account QUOTA)
 TheThe quotaquota command shows you how muchcommand shows you how much
storage space you have left in your account.storage space you have left in your account.
 When we use this command, we have to specifyWhen we use this command, we have to specify
the -v option to get the information forthe -v option to get the information for ourour
account.account.
 The format of this command is:The format of this command is:
quota -vquota -v
Familiar Commands:Familiar Commands:
oitcleaner (account cleaning tool)oitcleaner (account cleaning tool)
 TheThe oitcleaneroitcleaner account cleaning tool wasaccount cleaning tool was
developed by the UMBC OIT department.developed by the UMBC OIT department.
 This command is specific to the UMBC GL systems.This command is specific to the UMBC GL systems.
 This command takes no options and noThis command takes no options and no
filenames, so its format is:filenames, so its format is:
oitcleaneroitcleaner
Man PagesMan Pages
 TheThe manman command allows you to access thecommand allows you to access the
MANual pages for a UNIX command.MANual pages for a UNIX command.
 To get additional help on any of the commandsTo get additional help on any of the commands
listed below, you can always typelisted below, you can always type manman
name_of_commandname_of_command at the command prompt.at the command prompt.
 Examples:Examples:
 man sshman ssh
 man passwdman passwd
CommandsCommands
 ls :ls : lists the contents of a directorylists the contents of a directory
 l : long directory listingl : long directory listing
 a : lists all files, including files which are normally hiddena : lists all files, including files which are normally hidden
 F : distinguishes between directories and regular filesF : distinguishes between directories and regular files
 h : ? Look it up usingh : ? Look it up using manman
 pwdpwd : prints the current working directory: prints the current working directory
 cdcd : changes directories: changes directories
 The difference between relative and absolute paths.The difference between relative and absolute paths.
 Special charactersSpecial characters ..,, ...., and, and ~~..
 mkdirmkdir : creates a directory: creates a directory
 rmdirrmdir : removes a directory (assuming it is empty): removes a directory (assuming it is empty)
 If you get an error that the directory isn’t empty even though it looksIf you get an error that the directory isn’t empty even though it looks
empty, check for hidden files.empty, check for hidden files.
CommandsCommands
 touchtouch : creates an empty file with the specified name,: creates an empty file with the specified name,
or if the file already exists it modifies the timestamp.or if the file already exists it modifies the timestamp.
 rmrm : removes a file.: removes a file.
 f : force deletionf : force deletion
 r : recursive deletionr : recursive deletion
 mvmv - moves a file, or renames a file- moves a file, or renames a file
 f : forces overwrite, if the destination file existsf : forces overwrite, if the destination file exists
 cpcp - copies a file, leaving the original intact- copies a file, leaving the original intact
 f : forces overwrite, if the destination file existsf : forces overwrite, if the destination file exists
 r : recursive copying of directoriesr : recursive copying of directories
CommandsCommands
 catcat : shows the contents of a file, all at once: shows the contents of a file, all at once
 moremore : shows the contents of a file, screen by: shows the contents of a file, screen by
screenscreen
 lessless : also shows the contents of a file, screen by: also shows the contents of a file, screen by
screenscreen
 headhead : used to show so many lines form the top: used to show so many lines form the top
of a fileof a file
 tailtail : used to show so many lines form the: used to show so many lines form the
bottom of a filebottom of a file
CommandsCommands
 lprlpr : prints a file: prints a file
 aliasalias :: creates an alias for a command.creates an alias for a command.
 Aliases can be placed in yourAliases can be placed in your .cshrc.cshrc login script.login script.
 Example: alias rm ‘rm –i’.Example: alias rm ‘rm –i’.
 datedate : shows the date and time on the current system: shows the date and time on the current system
 whowho : used to print out a list of users on the current: used to print out a list of users on the current
systemsystem
 hostnamehostname : prints the hostname of the current: prints the hostname of the current
computercomputer
 whoamiwhoami : prints your current username: prints your current username
The UNIX Pipe (|)The UNIX Pipe (|)
 The pipe (|) creates a channel from one command to another.The pipe (|) creates a channel from one command to another.
Think of the pipe as a way of connecting the output from oneThink of the pipe as a way of connecting the output from one
command to the input of another command.command to the input of another command.
 The pipe can be used to link commands together to performThe pipe can be used to link commands together to perform
more complex tasks that would otherwise take multiple stepsmore complex tasks that would otherwise take multiple steps
(and possibly writing information to disk).(and possibly writing information to disk).
 Examples:Examples:
 Count the number of users logged onto the current system.Count the number of users logged onto the current system.
 TheThe whowho command will give us line by line output of all the current users.command will give us line by line output of all the current users.
 We could then use theWe could then use the wc -lwc -l to count the number of lines...to count the number of lines...
 who | wc –lwho | wc –l
 Display long listings in a scrollable page.Display long listings in a scrollable page.
 TheThe lpqlpq command will give us a list of the waiting print jobs.command will give us a list of the waiting print jobs.
 lpq | lesslpq | less
CommandsCommands
 psps : lists the processes running on the machine.: lists the processes running on the machine.
 ps -ups -u usernameusername lists only your processes.lists only your processes.
 ps -aps -a : lists all processes running on the machine.: lists all processes running on the machine.
 The PID column of the listing, provides the informationThe PID column of the listing, provides the information
required by the kill command.required by the kill command.
 killkill : terminates a process: terminates a process
 killkill process_idprocess_id : sends a terminate signal to the process: sends a terminate signal to the process
specified by thespecified by the process_idprocess_id (PID).(PID).
 In cases where the terminate signal does not work, theIn cases where the terminate signal does not work, the
command "command "killkill -9-9 process_idprocess_id" sends a kill signal to the process." sends a kill signal to the process.
 nicenice : runs a process with a lower priority.: runs a process with a lower priority.

More Related Content

What's hot

What's hot (20)

Linux Shortcuts and Commands:
Linux Shortcuts and Commands:Linux Shortcuts and Commands:
Linux Shortcuts and Commands:
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
Module 02 Using Linux Command Shell
Module 02 Using Linux Command ShellModule 02 Using Linux Command Shell
Module 02 Using Linux Command Shell
 
Os lab manual
Os lab manualOs lab manual
Os lab manual
 
Linux Basic commands and VI Editor
Linux Basic commands and VI EditorLinux Basic commands and VI Editor
Linux Basic commands and VI Editor
 
Command-Line 101
Command-Line 101Command-Line 101
Command-Line 101
 
InstallingRoRinLinux
InstallingRoRinLinuxInstallingRoRinLinux
InstallingRoRinLinux
 
One Page Linux Manual
One Page Linux ManualOne Page Linux Manual
One Page Linux Manual
 
Sahul
SahulSahul
Sahul
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
UNIX Command Cheat Sheets
UNIX Command Cheat SheetsUNIX Command Cheat Sheets
UNIX Command Cheat Sheets
 
Linux system admin useful commands
Linux system admin useful commandsLinux system admin useful commands
Linux system admin useful commands
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Exploring Code with Pry!
Exploring Code with Pry!Exploring Code with Pry!
Exploring Code with Pry!
 
Clase10 (consola linux)
Clase10 (consola linux)Clase10 (consola linux)
Clase10 (consola linux)
 
11 unix osx_commands
11 unix osx_commands11 unix osx_commands
11 unix osx_commands
 
Unix environment [autosaved]
Unix environment [autosaved]Unix environment [autosaved]
Unix environment [autosaved]
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 

Similar to Intro commandline

Similar to Intro commandline (20)

IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
IntroCommandLine.ppt
IntroCommandLine.pptIntroCommandLine.ppt
IntroCommandLine.ppt
 
Using Unix
Using UnixUsing Unix
Using Unix
 
cisco
ciscocisco
cisco
 
3. intro
3. intro3. intro
3. intro
 
Linux Command.pptx
Linux Command.pptxLinux Command.pptx
Linux Command.pptx
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
Linux week 2
Linux week 2Linux week 2
Linux week 2
 
Linux basic commands tutorial
Linux basic commands tutorialLinux basic commands tutorial
Linux basic commands tutorial
 
60761 linux
60761 linux60761 linux
60761 linux
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
Linux
LinuxLinux
Linux
 
Unit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-pptUnit 1-a-brief-history-of-unix-ppt
Unit 1-a-brief-history-of-unix-ppt
 
Linux
LinuxLinux
Linux
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 

Recently uploaded

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 

Recently uploaded (20)

Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 

Intro commandline

  • 1. Introducing theIntroducing the Command LineCommand Line CMSC 121 Introduction to UNIXCMSC 121 Introduction to UNIX Much of the material in these slides was taken fromMuch of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.Dan Hood’s CMSC 121 Lecture Notes.
  • 2. Format of UNIX CommandsFormat of UNIX Commands  UNIX commands can be very simple one word commands, or they can take aUNIX commands can be very simple one word commands, or they can take a number of additional arguments (parameters) as part of the command. Innumber of additional arguments (parameters) as part of the command. In general, a UNIX command has the following form:general, a UNIX command has the following form: command options(s) filename(s)command options(s) filename(s)  TheThe commandcommand is the name of the utility or program that we are going tois the name of the utility or program that we are going to execute.execute.  TheThe optionsoptions modify the way the command works. It is typical for these optionsmodify the way the command works. It is typical for these options to have be a hyphen followed by a single character, such asto have be a hyphen followed by a single character, such as -a-a. It is also a. It is also a common convention under Linux to have options that are in the form of 2common convention under Linux to have options that are in the form of 2 hyphens followed by a word or hyphenated words, such ashyphens followed by a word or hyphenated words, such as --color--color oror --pretty-print--pretty-print..  TheThe filenamefilename is the last argument for a lot of UNIX commands. It is simply theis the last argument for a lot of UNIX commands. It is simply the file or files that you want the command to work on. Not all commands workfile or files that you want the command to work on. Not all commands work on files, such ason files, such as sshssh, which takes the name of a host as its argument., which takes the name of a host as its argument.
  • 3. Common UNIX ConventionsCommon UNIX Conventions  In UNIX, the command is almost alwaysIn UNIX, the command is almost always entered in allentered in all lowercaselowercase characters.characters.  Typically any options come before filenames.Typically any options come before filenames.  Many times, individual options may need a wordMany times, individual options may need a word after them to designate some additional meaningafter them to designate some additional meaning to the command.to the command.
  • 4. Familiar Commands:Familiar Commands: scp (Secure CoPy)scp (Secure CoPy)  TheThe scpscp command is a way to copy files backcommand is a way to copy files back and forth between multiple computers.and forth between multiple computers.  Formats for this command:Formats for this command:  scp path/local_name username@hostname:path/remote_namescp path/local_name username@hostname:path/remote_name  scp username@hostname:path/remote_name path/local_namescp username@hostname:path/remote_name path/local_name  Demo with renaming and copying files.Demo with renaming and copying files.
  • 5. Familiar Commands:Familiar Commands: ssh (Secure SHell)ssh (Secure SHell)  TheThe sshssh command is a way to securely connect to a remote computer.command is a way to securely connect to a remote computer.  Formats for this command:Formats for this command:  ssh hostnamessh hostname  ssh username@hostnamessh username@hostname  ssh hostname -l usernamessh hostname -l username  If you do not specify the username, it will assume that you want to connectIf you do not specify the username, it will assume that you want to connect with the same username that you have on this local computer.with the same username that you have on this local computer.  Since you have a single username for all computers on the OIT network, youSince you have a single username for all computers on the OIT network, you don’t need to explicitly enter a username.don’t need to explicitly enter a username.  But you can give a username, and will need to if your local username is differentBut you can give a username, and will need to if your local username is different that your GL username. This might be the case if you are logging on from homethat your GL username. This might be the case if you are logging on from home and set up your username to be different from what it is on GL.and set up your username to be different from what it is on GL.  Demo with connecting with different usernames.Demo with connecting with different usernames.
  • 6. Familiar Commands:Familiar Commands: ssh (Secure SHell)ssh (Secure SHell)  You can save a couple of keystrokes if you are on oneYou can save a couple of keystrokes if you are on one of the Linux PCs in the labs:of the Linux PCs in the labs:  You really only need to specify enough of a hostname as youYou really only need to specify enough of a hostname as you may need.may need.  Linux will automatically attempt to fill out the hostname withLinux will automatically attempt to fill out the hostname with “umbc.edu” for you.“umbc.edu” for you.  So if you want to log onto the lightest loaded linux server onSo if you want to log onto the lightest loaded linux server on gl, you only need to issue the following command...gl, you only need to issue the following command... ssh linux.glssh linux.gl  Or, if you don't care the flavor of UNIX, you can simplyOr, if you don't care the flavor of UNIX, you can simply type...type... ssh glssh gl
  • 7. Familiar Commands:Familiar Commands: passwd (change PASSWorD)passwd (change PASSWorD)  TheThe passwdpasswd command changes your UNIXcommand changes your UNIX password.password.  This command is an example of a “noThis command is an example of a “no argument” command. Thus, the format of thisargument” command. Thus, the format of this command is just the command name itself.command is just the command name itself. passwdpasswd  passwd is an interactive command, as once wepasswd is an interactive command, as once we have typed it, we need to interact with it.have typed it, we need to interact with it.
  • 8. Familiar Commands:Familiar Commands: quota (account QUOTA)quota (account QUOTA)  TheThe quotaquota command shows you how muchcommand shows you how much storage space you have left in your account.storage space you have left in your account.  When we use this command, we have to specifyWhen we use this command, we have to specify the -v option to get the information forthe -v option to get the information for ourour account.account.  The format of this command is:The format of this command is: quota -vquota -v
  • 9. Familiar Commands:Familiar Commands: oitcleaner (account cleaning tool)oitcleaner (account cleaning tool)  TheThe oitcleaneroitcleaner account cleaning tool wasaccount cleaning tool was developed by the UMBC OIT department.developed by the UMBC OIT department.  This command is specific to the UMBC GL systems.This command is specific to the UMBC GL systems.  This command takes no options and noThis command takes no options and no filenames, so its format is:filenames, so its format is: oitcleaneroitcleaner
  • 10. Man PagesMan Pages  TheThe manman command allows you to access thecommand allows you to access the MANual pages for a UNIX command.MANual pages for a UNIX command.  To get additional help on any of the commandsTo get additional help on any of the commands listed below, you can always typelisted below, you can always type manman name_of_commandname_of_command at the command prompt.at the command prompt.  Examples:Examples:  man sshman ssh  man passwdman passwd
  • 11. CommandsCommands  ls :ls : lists the contents of a directorylists the contents of a directory  l : long directory listingl : long directory listing  a : lists all files, including files which are normally hiddena : lists all files, including files which are normally hidden  F : distinguishes between directories and regular filesF : distinguishes between directories and regular files  h : ? Look it up usingh : ? Look it up using manman  pwdpwd : prints the current working directory: prints the current working directory  cdcd : changes directories: changes directories  The difference between relative and absolute paths.The difference between relative and absolute paths.  Special charactersSpecial characters ..,, ...., and, and ~~..  mkdirmkdir : creates a directory: creates a directory  rmdirrmdir : removes a directory (assuming it is empty): removes a directory (assuming it is empty)  If you get an error that the directory isn’t empty even though it looksIf you get an error that the directory isn’t empty even though it looks empty, check for hidden files.empty, check for hidden files.
  • 12. CommandsCommands  touchtouch : creates an empty file with the specified name,: creates an empty file with the specified name, or if the file already exists it modifies the timestamp.or if the file already exists it modifies the timestamp.  rmrm : removes a file.: removes a file.  f : force deletionf : force deletion  r : recursive deletionr : recursive deletion  mvmv - moves a file, or renames a file- moves a file, or renames a file  f : forces overwrite, if the destination file existsf : forces overwrite, if the destination file exists  cpcp - copies a file, leaving the original intact- copies a file, leaving the original intact  f : forces overwrite, if the destination file existsf : forces overwrite, if the destination file exists  r : recursive copying of directoriesr : recursive copying of directories
  • 13. CommandsCommands  catcat : shows the contents of a file, all at once: shows the contents of a file, all at once  moremore : shows the contents of a file, screen by: shows the contents of a file, screen by screenscreen  lessless : also shows the contents of a file, screen by: also shows the contents of a file, screen by screenscreen  headhead : used to show so many lines form the top: used to show so many lines form the top of a fileof a file  tailtail : used to show so many lines form the: used to show so many lines form the bottom of a filebottom of a file
  • 14. CommandsCommands  lprlpr : prints a file: prints a file  aliasalias :: creates an alias for a command.creates an alias for a command.  Aliases can be placed in yourAliases can be placed in your .cshrc.cshrc login script.login script.  Example: alias rm ‘rm –i’.Example: alias rm ‘rm –i’.  datedate : shows the date and time on the current system: shows the date and time on the current system  whowho : used to print out a list of users on the current: used to print out a list of users on the current systemsystem  hostnamehostname : prints the hostname of the current: prints the hostname of the current computercomputer  whoamiwhoami : prints your current username: prints your current username
  • 15. The UNIX Pipe (|)The UNIX Pipe (|)  The pipe (|) creates a channel from one command to another.The pipe (|) creates a channel from one command to another. Think of the pipe as a way of connecting the output from oneThink of the pipe as a way of connecting the output from one command to the input of another command.command to the input of another command.  The pipe can be used to link commands together to performThe pipe can be used to link commands together to perform more complex tasks that would otherwise take multiple stepsmore complex tasks that would otherwise take multiple steps (and possibly writing information to disk).(and possibly writing information to disk).  Examples:Examples:  Count the number of users logged onto the current system.Count the number of users logged onto the current system.  TheThe whowho command will give us line by line output of all the current users.command will give us line by line output of all the current users.  We could then use theWe could then use the wc -lwc -l to count the number of lines...to count the number of lines...  who | wc –lwho | wc –l  Display long listings in a scrollable page.Display long listings in a scrollable page.  TheThe lpqlpq command will give us a list of the waiting print jobs.command will give us a list of the waiting print jobs.  lpq | lesslpq | less
  • 16.
  • 17. CommandsCommands  psps : lists the processes running on the machine.: lists the processes running on the machine.  ps -ups -u usernameusername lists only your processes.lists only your processes.  ps -aps -a : lists all processes running on the machine.: lists all processes running on the machine.  The PID column of the listing, provides the informationThe PID column of the listing, provides the information required by the kill command.required by the kill command.  killkill : terminates a process: terminates a process  killkill process_idprocess_id : sends a terminate signal to the process: sends a terminate signal to the process specified by thespecified by the process_idprocess_id (PID).(PID).  In cases where the terminate signal does not work, theIn cases where the terminate signal does not work, the command "command "killkill -9-9 process_idprocess_id" sends a kill signal to the process." sends a kill signal to the process.  nicenice : runs a process with a lower priority.: runs a process with a lower priority.