pratica pagina di riferimento ai comandi Linux trovata sulla rete,
di Frederik Holljen.
About this Document
Navigate Through the File System
Basic Command Separation
document is meant as a guide to essential command line programs for
Linux users and as a reference guide for other Help Files. The first
time I installed Linux and I no clue on what input to give my pc.
Step by step I found some useful commands. I remember thinking "Someone
should have a document with some basic commands listed that I could
use as a start to learn Linux". I have now used Linux since December
98 and I haven't seen such a document on the net, so I made on myself,
and here it is.
document is in NOT a complete reference on the commands in it, and
there are allot of other useful utilities in Linux. If you want any
additional information about a command use the man utility. If you
find any errors in this document or you think that I should add a
command, let me know.
This document is here for you!!
a lot of fun with Linux!!
Thanx to all the guys who have given me support with this document,
you know who you are!
When you call cd and give it a directory it will make the specified
directory the working directory. If you don't specify a target your
home directory will become the working directory.
MS USERS: When you want to descend a directory you have to write cd
.. with a space between the "d" and the first dot.
This command prints out the current working directory. This means
the full path of the directory that you are currently in.
ls [options] [file-list]
Lists information about one or more files. Lists alphabetically unless
you specify something else.
[file-list] could be any directory path or files you specify.
ls lists the working directory if you don't give
it this argument.
You can use wildcards * and ?.
-a All files, includes invisible files (those that start
with a period)
-l Long, displays extra information about the files.
-F Appends a "/" at the end of a directory listing
and a "*" at the end of an executable listing.
Makes the output of ls much more readable. Combine with --color.
--color Color, this command adds colors to the output
of ls. A very useful option, make an alias for it!!
cp [options] source-file destination-file
cp [options] source-file-list destination-directory
The program has two modes. You can copy one file into another. Or
copy a file from one place to another.
You can use wildcards * and ?.
-r Copies directories recursively. With this i mean
that all files including subdirectories and their content given by
source-file-list will be copied to the destination directory.
df [options] [filesystem-list]
If you don't specify the filesystem-list, df will list the amount
of available disk space on all mounted filesystems
-t type, causes df to display information about the type of the filesystems
of the specifies type.
Lists the diskspace used by the directory and its contents specified
by the directory-list argument
find directory expression
directory specifies the directory where you want the search to start.
Find will search all directories recursively.
expression is the search argument. These are the most common used:
-name filename, searches for the given filename
-user name, list all files who are owned by
the given users
-size +/-n, lists all files with size smaller/greater
ln [option] existing-file new-link
Creates a hard link to the file specified by existing-file with the
name given by the new-link argument. A hard link to a file is indistinguishable
from the original. A hard link has to be on the same filesystem as
the original file. A symbolic link may be across filesystems and existing
file and new-link may be directories as well as files.
-s creates a symbolic link instead
Lists all files in filedatabase that match the given pattern.
This utility depends on a database file with al list of all files
on your filesystem. Use the updatedb utility to update your database
(caution, this takes a while)
This search would find all files on you system that contain hepp.
It would find heppgr, tghepp and tyheppl.
mkdir [options] directory-list
Creates a new directory. If you write #mkdir test, mkdir creates a
new directory with the name "test" in the current directory.
If you want mkdir to make a directory in another directory, you must
specify the whole directory path.
-p parent, if the parent directory of the directory you are creating
does not exist, mkdir will create it for you.
mv [options] source-path destination-path
Copies the the files specified in source-path to destination path
and then deletes the original files.
You can use wildcards * and ?.
rm [options] file-list
This utility removes files from your system. You can use wildcards
* and ?.
Note: when you delete a file it is not possible to recover it.
-r recursive, this option makes rm remove
the specified directory and all of its contents. (MS USERS: Just like
deltree) BE CAREFUL WITH THIS COMMAND!!
-f force, this option makes rm delete files
without asking you if you really want to. Nice if you want to delete
Removes all directories specified by directory-list.
Note: The directories you want to delete must be empty. If they are
not, mkdir will fail. If you want to delete a directory together with
its contents use rm.
cat [options] [file-list]
cat lists all the files specified by file-list to your screen end
-n number, causes cat to display line numbers at the beginning of
echo [option] message
Very useful in scripting, lets you write messages to the terminal
and can be used to display shell variables
-n newline, prevents echo from displaying the newline at the end of
#echo -n 'Hi!'
#echo $TERM <-- this is a shell variable
grep [options] pattern [file-list]
This utility searches one or more files for a pattern. The grep utility
performs actions, specified by options every time
it finds a line that contains a match for the pattern.
If you use tabs or spaces in the
pattern you must quote it.
if you don't specify any options grep displays the line that contained
a match for pattern.
-c count, causes grep to display the number of times
it found a match for pattern
-i ignore case, ignores case when finding
a match for pattern
-l file list, causes grep to display only
the filename in which it found a match for pattern
-v reverse test, causes lines not containing a match
to satisfy the search
head [-number] [file-list]
The head utility displays ,without arguments, the ten first lines
of the files given by file-list. If you want to display more
or less than 10 lines specify this with the -number option.
If you don't specify any file-list head will read from it's
standard input. This means that you can pipe to it.
Similar to more but you can scroll backwards in the document too!
man [options] page
Man is the built in manual pager in Linux. It offers allot of flexibility,
and I must admit that I don't know the man utillity as good as I should.
The parameter page tells man what you want help for. Normally it is
a command but you can also specify a utility, function or some config
file you need help with. Use the interactive commands to navigate
inside the document.
There are ALLOT... use "man man" to find the apropriate one..
/"argument" Higlights all words that contain "argument".
q quit, quits man.
more [options] [file-list]
Allows you to view a text file at the terminal. Almost the same as
cat, but it pauses each time it fills the screen. On pause, you can
press ENTER to make more display one more line. If you press space
more fills another screen. More will display all the files given in
the file-list argument. If you don't give it the file-list argument,
more will read from it's standard input.
-n number of lines, specifies the number of
lines in a screenfull.
-d display, makes more display a explanatory message
after each screenful
+n line number, makes more start at line number
More has a lot of interesting commands that can be used whenever more
pauses here is a list of the most commonly used
d shows half a screenful
q exits from more
v starts up the vi editor with the current document at the current
line (very useful)
- display the last part (tail) of a file
tail [options] [file]
This utility displays the last part of the file specified by file.
If you don't specify a file it read's from it's standard input, this
means that you can pipe to it.
-n lines, the number of lines from the en of the
file you want tail to display.
tar key[options] [file-list]
The tar utlility can extract, add to, list, and create tar
volumes. It can also extract tar.gz/tgz archives.You can only have
one key mode, but you can have multiple options. The tar utility has
tons of options check them out in the manual (man tar)
t table of contents, displays all the files
in the archive.
A append, adds the files specified by file-list
c create, creates a new archive
x extract, extracts files from the archives given
v verbose, causes tar to display each line
as it reads/writes them.
-V name Create a volume with volumename NAME. Use
this together with the key A
z filter the archive through gzip. Use this when
you have a tgz/tar.gz file.
-f file input file, Unpack from archive "file" instead
of the standard input which is /dev/rtm0 (tape streamer)
finger [options] [user-list]
With no arguments finger gives you a list of all users logged on to
the system together with their full names, terminal device numbers
the number of times they logged in and other information. If specify
a user on the command line, finger gives you detailed information
on that user and displays his/her .plan, .project and .forward file.
The really cool thing with finger is that you can finger users on
[user] gives you information on that user on your local system
[user]@[host] gives you information on that particular user on that
@[host] lists all the users currently logged on on that host
-l long, gives you detailed information on
about every user currently logged on
kill [option] PID-list
Terminates all jobs with PID number=PID-list
You can determine what signal to send to terminate the process. These
are the possibilities
-0 sh(1) only, signals all members of process group
-9 non-catchable, non-ignorable kill (this is the one to use if you
process if doesn't want to get killed)
-15 software termination signal (default)
-HUP A very useful option. This causes kill to terminate
the process and to restart it afterwards.
Lists active processes. If you run ps without any options, it displays
all processes that you control. If you run ps without any options
you will see five columns
PID process ID, The process ID of the process on that line
TTY terminal, the terminal that controls the process
TIME The number of minutes and seconds the process has been running
COMMAND The command name with which the process was started. If you
use the w option you will see the entire command line.
a all, lists all processes controlled by any
e environment, Prints the environment of the
l long, a complete status report (13
u user, causes ps to display a userorientated
status information. Extra columns (CPU and MEM usage)
talk [user] [tty]
Allows you to real-time chat with any user given by [user]. If you
want to talk with someone on the local system [user] is just the username
of that person. If you want to talk to a user on a different host
[user] is [user@host]. If a user is logged in more than once, you
may want to specify the appropriate terminal. Do this with using the
[tty] option. It's on the form 'ttyXX'. To find out what tty's the
user you want to chat with uses, use the finger command.
When someone sends you a chat request you must reply with "talk [user]@[host]
or just [user] if the person is on the same system. Use ^c to quit
from the chat.
top [-] [options]
Gives you a list of existing processes and their activity in real
time. Defaults to sort processes by CPU activity, but can also sort
by MEM usage. It has both command line parameters and interactive
d [number] delay, the number of seconds between
i idle, causes top to ignore idle or zombie
SPACE causes top to update the screen immediately.
h help, gives you the help screen with a list
of commands (very useful)
k kill, Terminate a process. You will be prompted
for the PID to kill, and the signal to send.
s change the delay between each update. You
will be prompted for the time in seconds.
who [am i]
Who is a strip down of finger. With no arguments it displays the users
currently logged on, their terminal device number and the time they
logged on to the system.
Given the [am i] option who displays information about the current
ftp is the standard ftp client that comes with Linux. I recommend
installing something better (like ncftp). But I'll include it here
because it's a standard.. It's always there.. Ftp is interactive once
it's connected to a host.
escape to a shell on you local system. Use ^D to return to ftp.
binary set the file transfer type to binary
(you must do this if the files you want to download are non ASCII)
cd, change directory
close, close the connection but not ftp
dir/ls, list the files in the current
[local-file], download remote-file into local if specified.
mget remote-file-list, Allows
you to get multiple files (and directories) from the host. You can
puts local-file to the current directory on the host
mput local-file-list, Same as
mget only the other way.
help, display a list of available
Use this to write multiple lines command (if your terminal
screen isn't long enough).
#mount /dev/hdc \
Normally, when you enter a command, the task runs in the foreground
and you don't get the prompt back until
the program is finished. Sometimes you don't want this behavior. Especially
if your task takes a lot of time
and doesn't have any interaction with the user (example: updatedb).
The answer is to run the program in the
background. By placing a "&" last in your command you achieve
<Wait ten seconds>
#sleep 10 &
 13533 <-- this is the PID (ProcessID) of the process you just
put in the background.
# Your prompt returns immediately
#sleep 10 & sleep 15 &
 13534 <- starts both commands simultaneously in the background
 13535 <- this is the sleep 15 commands PID
A really useful separator. It directs the output of one command to
the next. This is very useful when you want one program to work on
the output of another one.
# ps aux | grep ps
larson 1344 0.0 0.4 1188 584 p2 R 15:04 0:00 ps aux
larson 1345 0.0 0.3 1180 464 p2 S 15:04 0:00 grep ps
The example first lists all processes on the system and directs this
output to the grep utility which sorts
out and displays all lines with ps in them. PS: you may not get the
same output that I did, because the "grep
ps" command may or may not have been started at the time you ask for
the process list.
If you want to execute more than one command in a row you can separate
them with a semicolon (;)
#cp /tmp/hello ; cat hello
Copies the file "hello" to the current directory and then displays