IntroCommandLine.pptbyTarakMdShabbieVeryeffective forthe students

sforbeautifulstories 0 views 17 slides Aug 31, 2025
Slide 1
Slide 1 of 17
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17

About This Presentation

This presentation provides a beginner-friendly introduction to the Command Line Interface (CLI). It explains what the command line is, why it is useful, and how to use it effectively for basic tasks. The slides cover key concepts, practical commands, and hands-on examples to help new users become co...


Slide Content

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 a UNIX commands can be very simple one word commands, or they can take a
number of additional arguments (parameters) as part of the command. In number 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)

The The commandcommand is the name of the utility or program that we are going to is the name of the utility or program that we are going to
execute. execute.

The The optionsoptions modify the way the command works. It is typical for these options modify the way the command works. It is typical for these options
to have be a hyphen followed by a single character, such as to 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 2 common convention under Linux to have options that are in the form of 2
hyphens followed by a word or hyphenated words, such as hyphens followed by a word or hyphenated words, such as --color--color or or ----
pretty-printpretty-print. .

The The filenamefilename is the last argument for a lot of UNIX commands. It is simply the is 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 work file or files that you want the command to work on. Not all commands work
on files, such as on 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 always In UNIX, the command is almost always
entered in all entered in all lowercaselowercase characters. characters.

Typically any options come before filenames.Typically any options come before filenames.

Many times, individual options may need a word Many times, individual options may need a word
after them to designate some additional meaning after them to designate some additional meaning
to the command. to the command.

Familiar Commands:Familiar Commands:
scp (Secure CoPy)scp (Secure CoPy)

The The scpscp command is a way to copy files back command 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)

The The 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 connect If 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, you Since 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 different But 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 home that 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 one You 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 you You really only need to specify enough of a hostname as you
may need.may need.

Linux will automatically attempt to fill out the hostname with Linux 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 on So 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 simply Or, 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)

The The passwdpasswd command changes your UNIX command changes your UNIX
password.password.

This command is an example of a “no This command is an example of a “no
argument” command. Thus, the format of this argument” 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 we passwd 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)

The The quotaquota command shows you how much command 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 specify When we use this command, we have to specify
the -v option to get the information for the -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)

The The oitcleaneroitcleaner account cleaning tool was account 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 no This command takes no options and no
filenames, so its format is:filenames, so its format is:
oitcleaneroitcleaner

Man PagesMan Pages

The The manman command allows you to access the command 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 commands To get additional help on any of the commands
listed below, you can always type listed below, you can always type man man
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 using h : ? 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 characters Special 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 looks If 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

alias alias :: creates an alias for a command.creates an alias for a command.

Aliases can be placed in your Aliases 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 one Think 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 perform The pipe can be used to link commands together to perform
more complex tasks that would otherwise take multiple steps more 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.

The The 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 the We 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.

The The 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 information The 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 the specified by the process_id process_id (PID).(PID).

In cases where the terminate signal does not work, the In 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.