Linux/UNIX Basic Shell Commands

Command Description
tcsh Running the TC Shell will enable these features: backspace, command line completion, and repeat a command. For commandline completion, pressing the tab key will complete a file name. To repeat a command, press the up and down arrow keys to scroll through a history of the commands, then press the enter key to execute the command. “tcsh” stands for TENEX C shell.
repeat a command To recall and re-execute previous commands, use the up-arrow key. Keep pressing this key until you find the command you want to reuse, then press the return/enter key. Note that you need to be in the “tcsh” shell for this to work.
ls [-l] [-a] Lists contents of directory (folder). Including the option -l gives more detail (protection, size, and date) -a causes ls to include files whose name starts with a period – they are not normally listed (wild cards OK) e. g. “ls ics212” lists all the files in the directory called ics212. “ls -a -l” lists all the files in your current directory, including files whose names start with . and this gives many details about the files. (Files whose names start with . are “hidden” files.)
* Many commands allow wild card characters in the file names. An * (asterisk) stands for any string of 0 or more characters. For example, *.c means all files that end with .c and “program*” means all files that start with “program” If you use * alone, it means all files.
? Many commands allow wild card characters in the file names. A ? (question mark) stands for any single character. For example, ?.c means all files that end with .c with one character names, and program.? means all files that start with “program” with one character file extensions. If you use ? alone, it means all files with one character names.
dir Will list all the files in the current directory (folder).
clear Clears out all the commands and output on the terminal window, and puts the
curser at the top of the terminal window.
history Displays the command history list with line numbers.
!! Will display and execute the last command issued.
vim filename Opens file in the vim editor. Creates a new file if not present.
emacs filename Opens file in the emacs editor. Creates new file if not present.
mkdir dirname Make a new directory e. g. “% mkdir assignments” makes a directory called
assignments
rm file Remove (delete, erase) a file or files (wild cards OK)
rmdir dirname Remove a directory
cp file1 file2 Copy file1 to file2.
mv file1 file2 Rename file1 to file2.
cd dirname Change directory. For example, “cd ics212” will change to the ics212 directory. “cd ..” will move one directory higher.
cat filename Display a file. For example, “cat aloha.c” will display the file aloha.c on your screen.
more filename Display file in controlled increments. For example, “cat aloha.c” will display the file aloha.c in one page increments.
less filename Display file. Option -N displays the line numbers. To quit, type q.
pwd Print working directory (your current directory)
man command Display on-line manual for command. For example, “man ls” will display a short manual on the “ls” command.
command > outputfile.txt Usually, output is displayed on the terminal
However, we can “redirect” where standard output is stored by using a command, followed by a greater-than-sign (>), and then a file name
The output will be stored in the file!
This stores the contents of the “ls” command in file1.txt:
ls > file1.txtThis stores contents of “history” command in file2.txt:
history > file2.txt
./program < inputfile.txt Likewise, you can use the less-than-sign (<) for input into a program. For
example, if your executable file (a compiled and linked file with machine code
used for program execution)
is called “program”, then you can use this
command for file input into your program:
./program < inputfile.txtYou can also use “redirection” for both file input and file output:./program < input.txt > output.txt
chmod Change file permission mode (wild cards OK). For example, to make a webpage viewable:

chmod 644 webpage.htm