File/Directory Basics
ls List files
pwd Print current working directory
cd Change directories
cp Copy files
mv Move/Rename files
rm Delete files
mkdir Create directory
rmdir Delete directory
File Viewing
cat View file contents
less Page through files
head View file beginning
tail View file ending
nl View file with line numbers
File Creation and Editing
emacs Text editor
vi Text editor
gedit Text editor
File Properties
stat Display file attributes
wc Count bytes/words/lines
file Identify file types
chown Change file owner
chgrp Change file group
chmod Change file permissions
Programming
g++ Compile a C++ program
gdb Starts the debugger
Usage Examples
$ ls lists files of your current working directory.
$ cd /home/mids/m012345/ change your working directory to your home directory using a full, or absolute, pathname
$ cd change your working directory to your home directory using a shortcut
$ mkdir lab creates a lab subdirectory in your current working directory
$ cd lab change your working directory to the lab directory in your home directory in this case
$ cd .. change your working directory to the parent directory, which is your home directory
$ gedit main.cpp creates the file main.cpp, if it doesn't already exist, and opens it in the gedit editing window
[1. OBSERVE that after this command the 'cursor' is not active, until you quit gedit.]
[2. Now, ENTER a simple C++ program inside the gedit window.]
[3. Finally, SAVE your program, then QUIT gedit]
$ gedit main.cpp & opens main.cpp for editing, in the "background"
[OBSERVE that after this command the 'cursor' *is* active, because of the ampersand at end of command]
[After observing this, you can quit gedit again.]
$ cp main.cpp lab/ copies the file main.cpp to the lab directory
$ mv main.cpp test.cpp renames main.cpp to test.cpp
$ mv test.cpp lab/lab1.cpp moves main.cpp to the lab directory under the new name of lab1.cpp
$ ls -l lab lists files in the lab directory in more detail
$ cat lab/main.cpp shows file contents of main.cpp, which is located in the lab directory
$ cd lab change working directory to 'lab'
$ g++ -Wall main.cpp compiles and links main.cpp (with warnings enabled) and creates an executable file called a.out
$ g++ -Wall -o proj main.cpp compiles and links main.cpp, and creates executable file called proj
$ rm main.cpp deletes main.cpp from the working directory. You may need to confirm by entering 'y' then [ENTER]
$ cd .. change your working directory to the parent directory, which is your home directory in this case
$ rm lab/lab1.cpp deletes lab1.cpp from the lab directory
$ rm lab/* deletes all files from the lab directory. * is a 'wildcard'
$ rmdir /home/m012345/lab deletes the lab directory using its absolute pathname.
 

This reference originally created by LT J Schultz, later modified by Assoc Prof Luke McDowell.

Valid XHTML 1.0 Strict