Useful Commands


Below is list of useful commands. Click the 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

$ cd documents

$ ls
budget  letter.txt

$ ls -F
documents/  downloads/  pictures/

$ ls -F documents
budget   letter.txt

$ ls -l
total 2
drwxr-xr-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

$ cd documents

$ ls -l
total 3
-rw------- 1 bobby users 1169 Oct  7 15:54 budget
-rw-r--r-- 1 bobby users 1324 Oct  7 15:56 letter.txt

$ ls -l -F ..
total 2
drwxr-xr-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/
mkdir Make directory
$ cd /home/bobby/pictures

$
cat Print file on standard output
This is example 8.
more Display a file, one screen at a time
This is example 9.
less Less is more (more or less)
This is example 10.
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.
mv Move or rename files
This is example 14.
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.