|
Quick Tips
- Linux |
| Basic Linux
Commands |
| |
| Make sure Caps
Lock is off - the following commands should be typed in
lower case. |
| |
| |
|
Clearing the
screen |
| |
| Type:
clear |
| |
| Listing
files and directories |
| |
| Type: ls |
| |
| Changing
directory |
| |
| Type: cd
<directory name> |
change
to the directory specified |
| Type: cd
.. |
change
to the parent directory |
| Type: cd |
change
to the home directory |
|
|
|
|
Copying a file |
|
|
|
Type: cp <source file>
<destination file> |
|
|
|
Deleting a file |
|
|
|
Type: rm <file name> |
|
|
| Making a
directory |
| |
| Type: mkdir
<directory name> |
|
|
|
Deleting a
directory |
|
|
|
Type: rm -r <directory
name> |
|
|
|
Viewing a
text file |
|
|
|
Type: cat
<file name> |
|
|
| Creating/editing a
text file |
| |
| Type: nano
<file name> |
| |
| ctrl+o writes
the file to disk |
| ctrl+x quits
nano editor |
| |
| Shell Scripts |
| |
|
A shell script is a file containing a series of
commands. The commands are executed automatically in the order they
appear in the file just as if they were
typed manually at the command prompt. |
| |
| A shell script
is a simple text file structured as follows: |
| |
| #!/bin/bash |
| command 1 |
| command 2 |
| command n |
| |
| Comments can
be added to the file as follows: |
| |
| # comments
start with a '#' |
| |
| A message can
be displayed by adding the following command: |
| |
| echo "this is
my message" |
| |
| It is good
practice to save the text/script file with a .sh extension e.g. myscript.sh |
| |
| Script files
must be made executable prior to use - use chmod (see below). |
| |
| To run the script type: ./myscript.sh |
| |
| Making a
file executable |
| |
| Type: chmod +x
<file name> |
| |
| Show the
Present/current Working Directory (PWD) |
| |
| Type: pwd |
| |
| Show
running processes |
| |
| Type: top |
| |
| ctrl+z quits
top |
| |
| Closing the
Unix shell (Bash) |
| |
| Type: exit |
| |
| |
| Quick Tip: |
|
You can use
the up and down arrow keys to scroll through a list of
previously typed commands. |
| |
| |