DEPARTMENT OF COMPUTING

IT 1100 : Introduction to Operating Systems

- Basic Commands


Command

Sample Usage

Description

ssh

ssh smorgan@ssh.cs.dixie.edu

ssh smorgan@scratch.cs.dixie.edu

allow remote connection to other computers

wget

wget http://www.google.com/somefile.pdf

copy a file from the internet

tar

tar -xvvf myfiles.tar

extract the tar file. This will put all of the files in your current directory. run the ls command to see them

date

date

shows the current date and time of the computer

cal

cal

shows a calendar and highlights the current date

exit

exit

logs you out and closes the terminal

pwd

pwd

prints the working directory or prints absolute path of the current directory

ls

ls

lists the contents of the current directory

ls newdirectory/

ls ~

ls /

lists the contents of a specified directory

ls -a

lists all the contents in a directory including the hidden ones

ls -l

lists the contents of a directory in long format

ls -r

lists the contents of a directory in reverse order

ls -t

lists the contents of a directory in date/time order

ls --color

lists the contents of a directory with color highlights.

ls -R

lists the contents of a directory and all of the subdirectories - same as tree

ls -a -l

ls -al

lists all the contents in a directory in long format

tree

tree

display the contents of a directory and all of the subdirectories - same as ls -R

cd

cd

cd ~

change directories to your user home directory or $HOME

cd newdirectory/

cd /var

change directories to the specified directory

cd -

return to the previous directory

echo

echo "Linux is Fun!"

print to the screen. quotations are optional, but helpful

less

less myfile.txt

display the contents of a file with the ability to navigate up and down

touch

touch newfile.txt

create an empty file

cp

cp myfile.txt myfile2.txt

copy a file

cp -r mydirectory copydirectory

copy a directory

mv

mv myfile.txt rabbits.txt

mv myfile.txt ../apple/myfile.txt

move or rename a file

mv mydirectory/ newdir/

mv mydirectory/ ../coconut/mydirectory/

move or rename a directory

rm

rm myfile.txt

remove a file

rm -r newdirectory/

remove a directory and all files inside

mkdir

mkdir mydirectory

make a new directory

ln

ln -s mydirectory/myfile name-of-symlink

ln -s /full/path/to/original /full/path/to/new/link

create a symbolic link, like a shortcut to a file or directory

Wildcard Characters

*

?

[ ]

[! ]

ls foo.*

list files ending with any extension. Any number of characters 0-infinity. Example foo.txt.backup

ls file?.txt

list files with exactly one character between file and the extension

ls file[1-3].txt

list files with a 1, 2, or 3 between file and the extension. Example file3.txt

ls file[1-3][a,z,f]*

list files with a 1, 2, or 3 followed by an a, z, or f followed by any number of characters. Example file2z.jpg

Last Updated 12/15/2017