-
Common Commands
Here is a list of helpful common commands used in a shell telnet environment.
man topic
Display the contents of the system manual pages (help) on the topic. Try
man man first. Press "q" to quit the viewer. The command info
topic works similar and may contain more up-to-date information.
Manual pages can be hard to read. Try any_command --help
for short, easy to digest help on a command.
apropos topic
Give a list of the commands that have something to to do with my topic.
help command
Display brief info on a bash (shell) build-in command.
ls
List the content of the current directory. Under Linux, the command "dir"
is an alias to ls. Many users have "ls" to be an alias to "ls --color".
ls -al |more
List the content of the current directory, all files (also those starting
with a dot), and in a long form. Pipe the output through the "more" command,
so that the display pauses after each screenful. hit space bar to go down a page
cd directory
Change directory. Using "cd" without the directory name will take you to
your home directory. "cd -" will take you to your previous directory and
is a convenient way to toggle between two directories. "cd .." will take
you one directory up.
cp source destination
Copy files. E.g., cp /home/stan/existing_file_name . will
copy a file to my current working directory. Use the "-r" option (for recursive)
to copy the contents of whole directories, e.g. , cp -r my_existing/dir/
~ will copy a subdirectory under my current working directory
to my home directory.
mv source destination
Move or rename files. The same command is used for moving and renaming files
and directories.
rm files
Remove (delete) files. You will be asked for confirmation of deleation, if
you don't want this, use the "-f" (=force) option, e.g., rm -f
* will remove all files in my current working directory, no questions
asked. BE CAREFUL HERE!!
mkdir directory
Make a new directory.
rmdir directory
Remove an empty directory.
rm -r files
(recursive remove) Remove files, directories, and their subdirectories. Careful
with this command, you can easily remove all files on the system with such
a command executed on the top of your directory tree, and there is no undelete
in Linux (yet).
cat filename | more
View the content of a text file called "filename", one page a time. The "|"
is the "pipe" symbol (on many American keyboards it shares the key with "\")
The pipe makes the output stop after each screenful. For long files, it is
sometimes convenient to use the commands head and tail that display just
the beginning and the end of the file. If you happened to use "cat" a binary
file and your terminal displays funny characters afterwards, you can restore
it with the command "reset".
less filename
Scroll through a content of a text file. Press q when done. "Less" is roughly
equivalent to "more" , the command you know from DOS, although very often
"less" is more convenient than "more".
pico filename
Edit a text file using the simple and standard text editor called
pico.
pico -w filename
Edit a text file, while disabling the long line wrap.
find / -name "filename"
Find the file called "filename" on your filesystem starting the search from
the root directory "/". The "filename" may contain wildcards (*,?).
locate filename
Find the file name of which contains the string "filename". Easier and faster
than the previous command but depends on a database that normally rebuilds
at night.
top
-
Editing Files Using vi
Below is a very short tutorial in the most basic use of the vi editor:
To get into a vi session:
~$ vi filename
This will open an existing file for editing or create the file and open for
editing if it does not exist.
To get out without saving:
:q!
To get out with saving:
:wq
To delete characters, type 'x' with cursor over character [ if in INSERT
mode, press Esc then x ]. To delete group of characters type '#x' where #
is the number of characters to be deleted.
To delete an entire line, type 'dd' at the beginning of the line.
To delete a group of lines type '#dd' where # is the number of lines to be
deleted.
INSERT MODE:
'INSERT' will appear at bottom of screen and remain while in insert mode.
Escape insert mode by hitting 'Esc' key. (You must escape insert mode or
any mode in order to save and/or quit)
To insert characters after the cursor, type 'i' . To insert characters before
the cursor, type 'a'. To insert characters at the end of the line, type 'A'
To open a line for insertion below the line the cursor is on, type 'o'. To
open a line for insertion above the line the cursor is on, type 'O'
To move forward a page type 'Ctrl f', backward a page type 'Ctrl b'. To move
quickly to the bottom of the file, type 'G'. To move quickly to the top of
a file, type '1G'.
To search, type '/search_string'. Type 'n' to get next instance of search
string.
Get a book for all the many other things that can be done with the 'vi' editor.
Alternatively or also, read the 'man' entries for vi. At prompt, type, 'man
vi'.
~$ man vi
top
-
Editing Files Using Pico (recommended for beginners)
Using Pico is highly recommended by beginners! It is fairly easy to use and a very good editor.
To start, type in:
pico -w filename
-if the "filename" is a new file, it will automatically create a new one, if it exists, it will edit the file
To search for something in the document: "Ctrl + W"
To exit, "Ctrl + X" and "y" to save your file
To Cut text out (cuts each line at a time), "Ctrl + K"
top
-
File Backups using Compression/Decompression
tar -zxvf filename.tar.gz
To Untar a tarred and compressed tarball (*.tar.gz or *.tgz)
that you downloaded from the Internet.
tar -xvf filename.tar
Untar a tarred but uncompressed tarball (*.tar).
gunzip filename.gz
Decompress a zipped file (*.gz" or *.z). Use gzip (also zip or
compress) if you wanted to compress files to this file format.
bunzip2 filename.bz2
(=big unzip) Decompress a file (*.bz2) zipped with bzip2 compression utility.
Used for big files.
unzip filename.zip
Decompress a file (*.zip) zipped with a compression utility compatible with
PKZIP for DOS.
unarj e filename.arj
Extract the content of an *.arj archive.
uudecode -o outputfile filename
Decode a file encoded with uuencode. uu-encoded files are
typically used for transfer of non-text files in e-mail (uuencode transforms
any file into an ASCII file).
top
-
Help! I cannot connect with SSH or Secure FTP!
For those on `Lion`, you will have to change your host to this:
Lion.performancehosting.net and make sure your port is correct.
top