Useful Commands

Below is list of useful commands. Click the Photo of command key arrow icon to display a usage example. For more detailed information on a command, run man command.

Command Description
 
man Display the on-line manual pages
$ man who
WHO(1)                           User Commands                          WHO(1)

NAME
       who - show who is logged on

SYNOPSIS
       who [OPTION]... [ FILE | ARG1 ARG2 ]

DESCRIPTION
       Print information about users who are currently logged in.

       -a, --all
              same as -b -d --login -p -r -t -T -u

       -b, --boot
              time of last system boot
...
who Show who is logged in
$ who
bobby    pts/2        2019-12-01 19:28 (192.168.1.1)
root     pts/4        2019-11-30 16:42 (login002)
betty    pts/11       2019-12-01 16:14 (192.168.1.4)
bubba    pts/8        2019-12-01 10:02 (wayback.wossamotta.edu)
passwd Modify your password
$ passwd
Changing password for user bobby.
Changing password for bobby.
(current) UNIX password: 
New password: 
BAD PASSWORD: The password fails the dictionary check - it is based on a
dictionary word
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
pwd Print name of current working directory
$ pwd
/home/bobby
cd Change current directory
$ cd documents

$ pwd
/home/bobby/documents

$ cd ../downloads

$ pwd
/home/bobby/downloads

$ cd

$ pwd
/home/bobby
ls List directory contents
$ cd /home/bobby

$ ls
documents  downloads  pictures

$ ls -l
total 2
drwxr-x--- 2 bobby users 2 Oct  7 16:01 documents
drwxr-x--- 3 bobby users 1 Oct  7 15:02 downloads
drwxr-x--- 4 bobby users 2 Oct  7 14:14 pictures

$ ls -F
documents/  downloads/  pictures/

$ ls documents
budget  letter.txt

$ cd pictures

$ ls *Dec*
2019Dec25_01.jpg  2019Dec25_05.jpg  2019Dec25_09.jpg  2019Dec25_13.jpg
2019Dec25_02.jpg  2019Dec25_06.jpg  2019Dec25_10.jpg  2019Dec25_14.jpg
2019Dec25_03.jpg  2019Dec25_07.jpg  2019Dec25_11.jpg  2019Dec25_15.jpg
2019Dec25_04.jpg  2019Dec25_08.jpg  2019Dec25_12.jpg
mkdir Make directory
$ cd /home/bobby/pictures

$ mkdir holidays

$ ls -l holidays
total 0

$ ls -ld holidays
drwxr-xr-x 2 bobby users 0 Jan 06 11:03 holidays
mv Move or rename files and directories
$ pwd
/home/bobby/pictures

$ ls -F
2018May18_01.jpg  2019Aug21_04.jpg  2019Dec25_08.jpg  2019Jul04_03.jpg
2018May18_02.jpg  2019Aug21_05.jpg  2019Dec25_09.jpg  2019Jul04_04.jpg
2018May18_03.jpg  2019Aug21_06.jpg  2019Dec25_10.jpg  2019Jul04_05.jpg
2018May18_04.jpg  2019Dec25_01.jpg  2019Dec25_11.jpg  2019Jul04_06.jpg
2018May18_05.jpg  2019Dec25_02.jpg  2019Dec25_12.jpg  2019Jul04_07.jpg
2018May18_06.jpg  2019Dec25_03.jpg  2019Dec25_13.jpg  2019Jul04_08.jpg
2018May18_07.jpg  2019Dec25_04.jpg  2019Dec25_14.jpg  2019Jul04_09.jpg
2019Aug21_01.jpg  2019Dec25_05.jpg  2019Dec25_15.jpg  2019Jul04_10.jpg
2019Aug21_02.jpg  2019Dec25_06.jpg  2019Jul04_01.jpg  holidays/
2019Aug21_03.jpg  2019Dec25_07.jpg  2019Jul04_02.jpg

$ mv *Dec25* holidays/

$ ls -F
2018May18_01.jpg  2018May18_07.jpg  2019Aug21_06.jpg  2019Jul04_06.jpg
2018May18_02.jpg  2019Aug21_01.jpg  2019Jul04_01.jpg  2019Jul04_07.jpg
2018May18_03.jpg  2019Aug21_02.jpg  2019Jul04_02.jpg  2019Jul04_08.jpg
2018May18_04.jpg  2019Aug21_03.jpg  2019Jul04_03.jpg  2019Jul04_09.jpg
2018May18_05.jpg  2019Aug21_04.jpg  2019Jul04_04.jpg  2019Jul04_10.jpg
2018May18_06.jpg  2019Aug21_05.jpg  2019Jul04_05.jpg  holidays/

$ ls holidays
2019Dec25_01.jpg  2019Dec25_05.jpg  2019Dec25_09.jpg  2019Dec25_13.jpg
2019Dec25_02.jpg  2019Dec25_06.jpg  2019Dec25_10.jpg  2019Dec25_14.jpg
2019Dec25_03.jpg  2019Dec25_07.jpg  2019Dec25_11.jpg  2019Dec25_15.jpg
2019Dec25_04.jpg  2019Dec25_08.jpg  2019Dec25_12.jpg

$ mv holidays christmas

$ ls -F
2018May18_01.jpg  2018May18_07.jpg  2019Aug21_06.jpg  2019Jul04_06.jpg
2018May18_02.jpg  2019Aug21_01.jpg  2019Jul04_01.jpg  2019Jul04_07.jpg
2018May18_03.jpg  2019Aug21_02.jpg  2019Jul04_02.jpg  2019Jul04_08.jpg
2018May18_04.jpg  2019Aug21_03.jpg  2019Jul04_03.jpg  2019Jul04_09.jpg
2018May18_05.jpg  2019Aug21_04.jpg  2019Jul04_04.jpg  2019Jul04_10.jpg
2018May18_06.jpg  2019Aug21_05.jpg  2019Jul04_05.jpg  christmas/
cat Print file on standard output
$ cd /home/bobby/documents

$ ls
budget   letter.txt

$ cat letter.txt
To Whom It May Concern,

Lorem ipsum dolor sit amet, et vel diam nominavi adversarium, utamur labores
postulant eam in. Ad quo ubique delicatissimi, ei elitr eligendi has. Alia
tollit definitiones qui in. Ea vis eripuit nusquam. Eos ceteros tibique
adversarium ne, nisl tota convenire at pri.

Nobis adolescens contentiones sed id, vis sonet neglegentur in, an tation
consetetur qui. Duo cu aliquip molestiae, decore numquam oporteat in sit. Ut
mea error option conclusionemque, in posse interesset ullamcorper eam, cum ex
assum maluisset. Ea eruditi nominati ius, ea quo soleat bonorum salutandi,
dictas corrumpit euripidis no vim.

An per habemus omittam philosophia. Pro ad verterem salutandi. Et ipsum oratio
consectetuer duo, mea ex vidit definitionem. Ad dolor albucius deleniti per,
postea ocurreret definitionem ex mea. Ei putent voluptua intellegat vel, pri
in liber quodsi lobortis, quis altera essent at his.

Laboramus elaboraret eu usu, pro labitur adipisci at, qui congue appetere
assueverit ea. Liber scribentur et mel. Ex pro nullam aliquam, in primis
hendrerit per, ea est inani quando. Quo ei quis sint dicit, te atqui quando
mel. An rebum sententiae incorrupte eum, sea timeam similique ne.

                                          Sincerely,


                                          Robert M. "Bobby" Baylor
more Display a file, one screen at a time
$ more letter.txt
To Whom It May Concern,

Lorem ipsum dolor sit amet, et vel diam nominavi adversarium, utamur labores
postulant eam in. Ad quo ubique delicatissimi, ei elitr eligendi has. Alia
tollit definitiones qui in. Ea vis eripuit nusquam. Eos ceteros tibique
adversarium ne, nisl tota convenire at pri.

Nobis adolescens contentiones sed id, vis sonet neglegentur in, an tation
consetetur qui. Duo cu aliquip molestiae, decore numquam oporteat in sit. Ut
mea error option conclusionemque, in posse interesset ullamcorper eam, cum ex
assum maluisset. Ea eruditi nominati ius, ea quo soleat bonorum salutandi,
dictas corrumpit euripidis no vim.

An per habemus omittam philosophia. Pro ad verterem salutandi. Et ipsum oratio
consectetuer duo, mea ex vidit definitionem. Ad dolor albucius deleniti per,
postea ocurreret definitionem ex mea. Ei putent voluptua intellegat vel, pri
in liber quodsi lobortis, quis altera essent at his.

Laboramus elaboraret eu usu, pro labitur adipisci at, qui congue appetere
assueverit ea. Liber scribentur et mel. Ex pro nullam aliquam, in primis
hendrerit per, ea est inani quando. Quo ei quis sint dicit, te atqui quando
mel. An rebum sententiae incorrupte eum, sea timeam similique ne.

--More--(90%)(press space to continue)

                                          Sincerely,


                                          Robert M. "Bobby" Baylor
less Less is more (more or less)
$ less letter.txt
To Whom It May Concern,

Lorem ipsum dolor sit amet, et vel diam nominavi adversarium, utamur labores
postulant eam in. Ad quo ubique delicatissimi, ei elitr eligendi has. Alia
tollit definitiones qui in. Ea vis eripuit nusquam. Eos ceteros tibique
adversarium ne, nisl tota convenire at pri.

Nobis adolescens contentiones sed id, vis sonet neglegentur in, an tation
consetetur qui. Duo cu aliquip molestiae, decore numquam oporteat in sit. Ut
mea error option conclusionemque, in posse interesset ullamcorper eam, cum ex
assum maluisset. Ea eruditi nominati ius, ea quo soleat bonorum salutandi,
dictas corrumpit euripidis no vim.

An per habemus omittam philosophia. Pro ad verterem salutandi. Et ipsum oratio
consectetuer duo, mea ex vidit definitionem. Ad dolor albucius deleniti per,
postea ocurreret definitionem ex mea. Ei putent voluptua intellegat vel, pri
in liber quodsi lobortis, quis altera essent at his.

Laboramus elaboraret eu usu, pro labitur adipisci at, qui congue appetere
assueverit ea. Liber scribentur et mel. Ex pro nullam aliquam, in primis
hendrerit per, ea est inani quando. Quo ei quis sint dicit, te atqui quando
mel. An rebum sententiae incorrupte eum, sea timeam similique ne.

:(press space to continue)

                                          Sincerely,


                                          Robert M. "Bobby" Baylor
(END)(press q to quit)
head Display the first part of a file
This is example 11.
tail Display the last part of a file
This is example 12.
cp Copy files and directories
This is example 13.
rm Remove/delete a file
This is example 15.
nano Simple text editor
This is example 16.
vi Text editor
This is example 17.
emacs Text editor
This is example 18.
gedit Graphical text editor
This is example 19.
id Print user identity
This is example 20.
whoami Print username
This is example 21.
groups Print the groups a user is in
This is example 22.
chmod Change file access permissions
This is example 23.
which Show the full path of a command
This is example 24.
touch Change file access and modification time
This is example 25.
echo Output a line of text
This is example 26.
date Prints the system date and time
This is example 27.
w Show who is logged in and what they are doing
This is example 28.
top Display and update sorted information about processes
This is example 29.
wc Print line, word, and character counts for a file
This is example 30.
file Determine file type
This is example 31.
gzip,gunzip Compress or expand files
This is example 32.
hostname Show the system's host name
This is example 33.
ssh Remote login program
This is example 34.
diff Compare files line by line
This is example 35.
grep Search a file for a string or pattern
This is example 36.
ed Line-oriented text editor
This is example 37.
ps Process status
This is example 38.
sleep Delay for a specified amount of time
This is example 39.
env,printenv,set Print environment variables
This is example 40.