Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
UNIX Commands

UNIX commands

UNIX commands are the command line instructions you enter into a terminal, such as the one in Replit.Unix commands are cryptic, usually between two to five characters in length. However, they represent the function they perform. For example, ls is the command to get a directory listing. The general format for Unix commands is:

command -options arguments

where "command" is the name of some command followed by a number of options or arguments. Options are generally single characters that represent specific options. The minus sign "-" should be entered before an option.

Type in ls
and then type in ls -l

Unix is case-sensitive, so be sure you enter the options and arguments in the proper case. Generally lower case is used for commands.

Some UNIX commands

touch

Create a new file, such as touch hello.cpp

cd path

change directory.

cd

change to home directory

cp path1 path2

Copy file(s).

chmod permissions path

change the mode, the permissions, on a file or directory.
chmod 755 file sets the file permissions to: rwx r-x r-x
            Owner read, write, execute
            Group read, no write, execute
            World read, no write, execute
chmod 700 file sets the file permissions to: rwx --- ---
            Owner read, write, execute
            Group no read, no write, no execute
            World no read, no write, no execute
(Binary bells should be ringing in your head by now.)

ls

to get a listing of files in a directory
ls -l gives a long listing, showing permissions.

man command

to get a Unix Manual entry for a command.
e.g. man passwd

man -k topic

use the -k option to find all the entries for a specific topic.
e.g. man -k password

mkdir path

make a directory

more command

When the command is executed, more pauses the output when the screen is full. You can view the next screenful or just the next line. Look for the instructions at the bottom of the screen. Enter q to exit more.

mv file1 file2

move file1 to file2 or rename file1 to file2. The original file is deleted.

passwd

Change your Unix password.

pwd

print working directory, i.e. show current path.
In other words: where am I in the Unix file system.

rm path

to delete (remove) a file

rmdir path

to delete (remove) a directory.

script file_name

cause everything that appears on the screen to be placed in the file_name.
Turn this off by entering ^d (control-d).

A complete UNIX tutorial can be found on http://www.ee.surrey.ac.uk/Teaching/Unix/