Using Linux

Linux (pronounced lee-nucks) is the name given to a family of Unix-like operating systems. The Linux kernel was originally developed by Linus Torvalds in 1991. Red Hat Enterprise Linux is the operating system on Super Computing Wales which was originally developed by Red Hat Incorporated in 1993. Linux was originally developed as a free Unix-like operating system for Intel x86 based personal computers. It has since been ported to more computer hardware platforms than any other operating system. It is a leading operating system on servers and other big iron systems such as mainframes and supercomputers.

Command Prompt Basics

Command Description
man man displays manual information on the manual command
man <command> displays manual information on <command>
clear clears the screen
exit exits the command interpreter

Manipulating Directories

Command Description
cd .. change to the parent directory
cd <directory> change to directory <directory>
mkdir <directory> create directory <directory>
rmdir <directory> remove directory <directory>

Listing Files

Command Description
ls display list of files and sub directories in standard format < name > excluding hidden files
ls -a display list of files and sub directories in standard format < name > including hidden files
ls -l display list of files and sub directories in long format < permissions owner group size date time name >
ls -lh display list of files and sub directories in long format < permissions owner group size date time name > with human readable size
ls -lt display list of files and sub directories in long format < permissions owner group size date time name > sorted by time
ls -lr display list of files and sub directories in long format < permissions owner group size date time name > in reverse order
ls -ltrh display list of files and sub directories in long format < permissions owner group size date time name > sorted by time, in reverse order, with human readable size

Moving Files

Command Description
mv <source> <dest> move file <source> to file <dest>
mv -i <source> <dest> move file <source> to file <dest> prompt before overwriting if it exists
mv -f <source> <dest> move file <source> to file <dest> overwrite <dest> if it exists

Removing Files

Command Description
rm <file> remove file <file>
rm -i <file> remove file <file> prompt before removing
rm -r <directory> remove directory <directory>
rm –rf <directory> remove all sub directories and files

Copying Files

Command Description
cp <source> <dest> copy file <source> to file <dest>
cp -i <source> <dest> copy file <source> to file <dest> prompt before overwriting <dest> if it exists
cp -r <source> <dest> copy directory <source> to directory <dest> copy all sub directories and files

Comparing Files

Command Description
diff <file1> <file2> display differences between <file1> and <file2>
fgrep “string” <file> find “string” in <file>
sort <file> sorts each line in <file> alphanumerically

Other Commands

Command Description
who show who is logged on
top show which tasks are running
watch <command> run <command> repeatedly
history show which commands you ran
date display the date and time
time <command> displays the time taken to run <command>
more <file> displays a file on screen
cat <file> <files> concatenate file or files and print on screen
head <file> print top of file on screen
tail <file> print bottom of file on screen
uniq <file> omit repeated lines

Command Modifiers

Wildcards allow you to specify multiple items to operate on

ls *.txt rm *.txt

 

Redirection allows you to direct the output of one command to a file

sort unsorted.txt > sorted.txt

 

Filters are external commands that change data in some manner

fgrep “string” <file>

 

Pipes let you direct the output of one command as input to another

ls | fgrep "txt"