Linux Command Reference

Operation Command Usage Example
Find out where you are ... your present working directory pwd

(displays the full pathname of your current directory)
List the files in the current directory ls


ls -l


ls -a
ls lists just the names of the files in the current directory;
ls -l gives a long listing that includes the file name, permissions, the owner, the size, and the date;
ls -a lists all files in the directory, including some system files whose names start with a period;
ls -la gives a long listing of all files;
ls -l s* gives a long listing of all files whose name starts with s. (There are lots of other variations!)
Create (make) a new subdirectory of your current working directory mkdir directory_name
mkdir lab1

(creates a directory named lab1 within your current directory)
Change to another directory cd pathname

cd lab1

(Changes to the lab1 subdirectory of your current directory)

cd ~jdoe/cs120/labs/lab1

(Changes to user jdoe's lab1 directory)
Copy a file cp originalFile newFile


cp originalFile newDirectory

cp ~prof/cs120/assignments

(copies a file named into the assignments subdirectory of user "prof")


(copies a file named into a file named (in the same directory);

WARNING: if there was already a file named it would be wiped out!)

cp ~cpsc/ .

(copies a file named in the cpsc home directory to the present directory (that is what the dot means))
Rename a file (same as moving it to a file with a different name) mv oldName newName


renames the file; the new name is
WARNING: If there was already a file named it would be erased by this command.
Print a file nenscript -2rG filename

nenscript -2rG

(prints the file in a nice format (that saves paper!) to the lab printer)

View a file on the screen
more filename


less filename

(displays the contents of the file on the monitor one page at a time. Press the space bar to go to the next page; type b to go back to the previous page; type q to quit. less is similar.)
Delete (remove) a file rm filename


(deletes the file in the current directory)
Delete (remove) a directory rmdir directoryName

rmdir lab1

(removes the directory lab1 from the current directory. The directory must be empty to remove it.)