Project:Sandbox

Basic Linux Commands

Purpose: Use this job aid as a quick reference to basic Linux commands that will be used throughout the course.

You can view here in the following table the basic Linux commands that will be used throughout the course. The table provided below includes Linux commands that can be used to work with files and directories.

Files and Directory Linux Commands

Files and Directories    Linux Commands    Description/Comments Command manual          man        Find the manual entry for this. man –k      Show all the manual entries that contain this. man man               Displays the manual page for man.

Command information --- info        Show the information system entry for this command. Using info info shows a tutorial of the info documentation system.

Print to standard out -cat -Concatenate and print; print the named file to the terminal screen.

List users -cat /etc/passwd ---Concatenate and print out the contents of the password file to see the users.

Change working directory ---cd -Change working directory to specified directory cd with no parameters changes to $HOME.

Copy a file --cp   -Copy a source file to a destination file.

View a file -less View a file a page at a time. This is a GNU version of more, or pg. View a file -more View a file a page at a time. BSD version.

List directory--ls ---Options: –l : long  -R : recursive, -a : show hidden files, -t : sort by time,                           -r :reverse               sort, default            directory is current working directory.

Create a directory -mkdir -Make a directory defaults into the current working directory, full path may be specified.

Move or rename a file -mv   -Move changes the name of a file or moves it to a different directory.

Process List -ps    ps -ef -Shows the processes report

Shows all processes on the system with a full listing. Many option exist see the man page for details.

Print working directory -pwd -Print to stdout the current working directory.

Remove or erase a file --rm ---Removing a file on Linux is permanent. Options –r : recursive, and –f : force (including subdirectories) are very dangerous. Often the rm command is aliased with rm –i

The option –i asks 'Are you sure?'

Create an empty file -touch ---Create a file

Name of the machine -machine hostname  -Returns the name of the machine. The IP address of the machine host  --Queries the Domain Name Server, and returns the IP address of the machine name.

Remote shell -- rsh Execute a on. RSH is not secure, use ssh instead

Remote shell -- ssh -Secure shell, has features to replace rsh, rcp, ftp, and telnet. Remote shell -- telnet Start a terminal session on. Telnet is not secure, use ssh instead.

Search a file for a pattern --grep  -Search a or stream for a regular expression defined by and show the line that contains that pattern. A common option is –i for case insensitive. grep can accept input from a file or stdin through a pipe as in: netstat –a| grep ESTABLISHED

Source a script.  -In the bash shell this command '.' forces the script to run in the shell. Normal behavior is for the script to run in a child shell.

An interpreter -awk A macro language for reformatting or interpreting input. For each line of input, a variety of actions can be taken. May be referred to as nawk – for "new awk."

Sort a file - sort -Sort a file takes input from stdin or a filename argument, many options to sort by a particular column, field, etc. See man page.

Command-line editor ---sed --Sed is a command-line editor, with many possible commands and options that are very good for editing from a shell script.