Linux Man Pages
Linux CMD Tipps
Linux Commands
Dies ist ein praktisches Auswahl der Befehle, die wir am häufigsten unter Linux verwenden. Die
Taste drückt man ums zu sehen welche Linux Kommandos verfügbar sind (im eigenen PATH). Auf meinem Linux System sagt mir die Ausgabe, dass mir 2595 Kommandos in meinem PATH verfügbar sind. Viele dieser „Befehle“ können von Ihrem Lieblings Benutzeroberfläche (z.B. KDE oder Gnome) aus verwendet werden. Sie alle können von der Kommandozeile aus ausgeführt werden.
Erklärung:
<> = Sonder- oder Funktionstasten auf der Tastatur. Beispielsweise meint
<Ctrl> „control“ Taste.
italic = Name einer Datei oder einer Variablen die durch Ihre eigene ersetzt wird.
= in-line Linux Kommandos & Filenamen.
Hinweise für die UNIX Bedienung:
- Linux Groß- und Kleinschreibung. Als Beispiel: Netscape, NETSCAPE sind jeweils drei verschiedene Befehle. Auch meine_datei, meine_datei und meine_datei sind jeweils drei verschiedene Dateien. Ihren Benutzernamen und das Passwort sind auch Groß-und Kleinschreibungs abhängig.
(Dies geht auf die Tradition von UNIX und der „c“ Programmiersprache zurück welche ebenfalls case sensitive sind.)
- Dateinamen können bis zu 256 Zeichen lang sein und Buchstaben als auch Nummern enthalten „.“ (Punkt), „_“ (Unterstrich), „-“ (Bindestrich), plus sowie einige andere nicht erwähnte Zeichen.
- Dateinamen die mit „.“ beginnen sind werden normaln nicht mit dem
(list) oder
Kommando angezeigt. Diese Dateien sind „verseckt“. Benutze
(list mit der option „all“) um auch diese Dateien zu sehen.
- „/“ is an equivalent to DOS „“ (root Verzeichnis, meaning the parent
of all other directories).
- Unter Linux werden alle Verzeichnisse in einem einzigen Verzeichnisbaum angezeigt (es gibt keine Laufwerksbuchstaben im DOS-Stil ).
- In einer Konfigurationsdatei, eine Linie, beginnend mit # ist ein Kommentar.
Linux – wichtige Shortcuts & Kommandos
|
<Ctrl><Alt><F1> |
Wechseln Sie in das erste Text-Terminal. Unter Linux können Sie zur gleichen Zeit mehrere (6 in der Standard Einstellung) Terminals eröffnet.
<Ctrl><Alt><Fn> (n=1..6)
Wechseln ins nächste Terminal
Gibt den Namen des Terminals aus in dem sie sich gerade befinden.
<Ctrl><Alt><F7>
Wechselt ins GUI terminal (falls X-windows auf ihrem Linux Rechner läuft).
|
<Ctrl><Alt><Fn> |
(n=7..12)
Wechselt zum nächsten GUI terminal (falls ein GUI terminal auf screen
n-1 läuft). In der Standarteinstellung läuft aber normalerweise nichts in den Terminalfenstern
8 bis 12, aber das kann eingestellt werden.
(In einem Text Terminal) Vervollständigt automatisch das Kommando falls es einmalig ist, oder zeigt im anderen Fall eine Liste allr anderen Möglichkeiten.
Scrollen und die Kommando History editieren. Drücken der <Enter> Taste um den Befehl auszuführen.
|
<Shift><PgUp> |
Scrollen Terminal Ausgabe hoch. Funktioniert auch am login prompt, womit man sich die bootup messages ansehen kann.
|
<Shift><PgDown> |
Scrollen Terminal Ausgabe runter.
|
<Ctrl><Alt><+> |
(in X-windows) Ändern der X-server Auflösung (Wenn der X-server mit mehr als einer Auflösung konfiguriert ist). Für multible Auflösungen meiner SVGA Karte/Monitor, habe ich folgende Zeile in der Datei
(die erste Auflösung startet bei default, die größte bestimmt die Größe des „virtual screen“):
|
Modes "1024x768" "800x600" "640x480" "512x384" "480x300" "400x300" "1152x864" |
<Ctrl><Alt><->
(in X-windows) Ändern der X-server Auflösung in die Vorherige
<Ctrl><Alt><BkSpc>
(in X-windows) Beendet den momentanen X-windows server. Wird benutzt wenn der X-windows
server abstürzt und nicht normal beendet werden kann.
<Ctrl><Alt><Del>
Fährt das System herunter und rebootet. Dies ist der normale shutdown Befehl
für einen User auf der text-mode Console.
<Ctrl>c
Beendet den aktuellen Prozess (meist im text Modus bei kleinen Programmen).
<Ctrl>d
Logt aus dem aktuellen Terminal aus.
<Ctrl>d
Sendet [End-of-File] zum aktuellen Prozess. Nicht doppelt drücken den das bedeutet Logout
<Ctrl>s
Stopt den Transfare zum Terminal.
<Ctrl>q
Nimmt den Transfare zum Terminal wieder auf. Wird verwendet falls das Terminal mysteriöserweise
das responsing stoppt.
<Ctrl>z
Sendet den aktuellen Prozess in den Hintergrund
exit
Logout. Man kann auch
verwenden, der das selbe bewirkt (Falls eine zweite Shell gestartet wurde, e.g., verwende
in der zweiten Shell
wird ausgelogt und man ist zurück in der ersten Shell)
reset
Restore a screwed-up terminal (a terminal showing funny characters)
to default setting. Use if you tried to „cat“ a binary file. You may not
be able to see the Befehl as you type it.
|
<MiddleMouseButton> |
Paste the text which is Aktuellely highlighted somewhere else. This
is the normal „copy-paste“ operation in Linux. (It doesn’t work with
Netscape and WordPerfect which use the MS Windows-style „copy-paste“. It
does work in the text terminal if you enabled „gpm“ service using „setup“.)
Best used with a Linux-ready 3-button mouse (Logitech or similar) or else
set „3-mouse button emulation“).
(tilde) Das Home Verzeichnis (normally the Verzeichnis
).
Beispielsweise, the Befehl
will Ändert my working
Verzeichnis to the subVerzeichnis „my_dir“ under my home Verzeichnis.
Typing just „cd“ alone is an equivalent of the Befehl „cd ~“.
(Punkt) Aktuelle Verzeichnis. Beispielsweise,
will attempt
to ausführen die Datei „my_program“ located in your Aktuelles Arbeits Verzeichnis.
(Zwei Punkte) Verzeichnis parent to the Aktuelle one. Beispielsweise, the Befehl
will Ändert my Aktuelle working Verzeichnis one one level up.
Common Linux Befehls–system info
Print working Direktory – Ausgabe des aktuellen Verzeichnisses, – zeigt den Namen meines aktuellen Verzeichnis
auf dem Bildschirm
hostname
Zeigt den Hostnamen (der Linux-Pc auf dem sie arbeiten).
Benutze
(Als root) um den Namen des Linux-PCs zu ändern
whoami
Ausgabe meines Login Namens.
id
username
Ausgabe der id (uid) und der Gruppen id (gid), der Effective id (falls anderst als die reale id) und die Supplementary Gruppen
date
Ausgabe oder Änderung des System Datums und der System Zeit. Beispielsweise kann man mit folgenem Befehl die Systemzeit auf 2010-12-31 23:57 ändern
To set the hardware (BIOS) clock from the system (Linux) clock, use
the Befehl (Als root)
time
Determine the amount of time that it takes for a process to complete
+ other info. Don’t confuse it with the
Befehl. E.g.
I can
find out how long it takes to display a Verzeichnis content using:
Determine the users logged on the machine.
rwho -a
(=remote who) Determine all users logged on your network. The rwho
service must be enabled for this Befehl to run. If it isn’t, run setup
Als root to enable „rwho“.
finger
user_name
System info about a user. Try:
last
Zeigt eine Liste aller User die zu letzt in ihrem System eingeloggt waren.
history | more
Zeigt die letzten (100 oder so) Befehls ausführend from the Befehl line
on the Aktuelle account. The „| more“ causes the display to stop after each
screenful.
uptime
Show the amount of time since the last reboot.
ps
(=print status) Listet alle Prozesse auf die aktuell unter dem aktuellen User laufen.
ps axu | more
List all the processes Aktuellely running, even those without the controlling
terminal, together with the name of the user that owns each process.
top
Keep listing the Aktuellely running processes, sorted by cpu usage (top
users first). In KDE, you can get GUI-based Ktop from „K“menu under „System“-„Task
Manager“ (or by executing „ktop“ in an X-terminal).
uname -a
(= Unix name with option „all“) Info on your (local) server. I can
also use
(in X-window terminal) to display the info more
nicely.
free
Memory info (in kilobytes).
df -h
(=disk free) Print disk info about all the dateienystems (in human-readable
form)
du / -bh | more
(=disk usage) Print detailed disk usage for each subVerzeichnis starting
at the „/“ (root) Verzeichnis (in human legible form).
cat /proc/cpuinfo
Cpu info–it show the content of the file
. Note that
the dateien in the
Verzeichnis are not real dateien–they are
hooks to look at information available to the kernel.
cat /proc/interrupts
List the interrupts in use.
cat /proc/version
Linux Version und andere Informationen
cat /proc/dateienystems
Zeigt die Arten der Dateienysteme die momentan in Verwendung sind.
cat /etc/printcap
Zeigt die Eistellungen der Drucker.
lsmod
(Als root. Use
to ausführen this Befehl when you
are a non-root user.) Show the kernel modules Aktuellely loaded.
set|more
Show the Aktuelle user environment.
echo $PATH
Show the content of the environment variable „PATH“. This Befehl can
be used to show other environment variables as well. Use „set“ to see the
full environment.
dmesg | less
Ausgabe der kernel messages (the content of the so-called kernel ring buffer).
Drücken „q“ to quit „less“. Benutze
to see
what „dmesg“ dumped into this file right after the last system bootup.
Grundlegende Linux Operationen
|
<em>any_Befehl </em>--help |more |
Display a brief help on a Befehl (works with most Befehls). „–help“
works similar to DOS „/h“ switch. The „more“ pipe is needed if the output
is longer than one screen.
man
topic
Display the contents of the system manual pages (help) on the topic.
Try
first. Drücken „q“ to quit the viewer. The Befehl
works similar and may contain more up-to-date information. Manual pages
can be hard to read. Try
|
<em>any_Befehl</em> --help |
for short,
easy to digest help on a Befehl. If more info needed, have a look to the
Verzeichnis
. To display manual page from a specific section,
I may use something like in this example:
(this
displays an info on the Befehl
from section 3 of the manual
pages).
apropos
topic
Give me the list of the Befehls that have something to to do with
my topic.
help Befehl
Display brief info on a bash (shell) build-in Befehl.
ls
List the content of the Aktuelle Verzeichnis. Under Linux, the Befehl
„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 Aktuelle Verzeichnis, all dateien (also those starting
with a dot), and in a long form. Pipe the output through the „more“ Befehl,
so that the display pauses after each screenful.
cd
Verzeichnis
Ändert Verzeichnis. Using „cd“ without the Verzeichnis name will take you
to your home Verzeichnis. „cd -“ will take you to your previous Verzeichnis
and is a convenient way to toggle between two directories. „cd ..“ will
take you one Verzeichnis up.
cp
source destination
Dateien kopieren. E.g.,
|
cp /home/stan/existing_file_name . |
will copy a file to my Aktuelle working Verzeichnis. Use the „-r“ option (for
recursive) to copy the contents of whole directories, e.g. ,
will copy a subVerzeichnis under my Aktuelle
working Verzeichnis to my home Verzeichnis.
mcopy
source destination
Kopiert eine Datei from/to a DOS dateienystem (no mounting necessary). E.g.,
|
mcopy a:autoexec.bat ~/junk |
. See
for related Befehls:
mdir, mcd, mren, mmove, mdel, mmd, mrd, mformat ….
mv source destination
Move or rename dateien. The same Befehl is used for moving and renaming
dateien and directories.
ln
source destination
Erstellt a hard link called destination to the file called source.
The link appears as a copy of the original dateien, but in reality only one
copy of the file is kept, just two (or more) Verzeichnis entries point to
it. Any Änderts the file are automatically visible throughout. When one
Verzeichnis entry is Entferntd, the other(s) stay(s) intact. The limitation
of the hard links are: the dateien have to be on the same dateienystem, hard
links to directories or special dateien are impossible.
ln -s source destination
Erstellt einen Symbolic (soft) Link called „destination“ to the file called
„source“. The symbolic link just specifies a path where to look for the
file. In contradistinction to hard links, the source and destination don’t
not have to tbe on the same dateienystem. In comparison to hard links, the
drawback of symbolic links are: if the original file is Entferntd, the link
is „broken“, symbolic links can also Erstellt circular references (like circular
references in spreadsheets or databases, e.g., „a“ points to „b“ and „b“
points back to „a“).
rm dateien
Entfernt (delete) dateien. You must own the file in order to be able to
Entfernt it. On many systems, you will be asked or confirmation of deleation,
if you don’t want this, use the „-f“ (=force) option, e.g.,
will Entfernt all dateien in my Aktuelle working Verzeichnis, no questions asked.
mkdir
Verzeichnis
Make a new Verzeichnis.
rmdir
Verzeichnis
Entfernt an empty Verzeichnis.
rm -r dateien
(recursive Entfernt) Entfernt dateien, directories, and their subdirectories.
Careful with this Befehl Als root–you can easily Entfernt all dateien on the
system with such a Befehl ausführend on the top of your Verzeichnis tree,
and there is no undelete in Linux (yet). But if you really wanted to do
it (reconsider), here is how (Als root):
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 dateien, it is sometimes convenient to use the Befehls 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 Befehl „reset“.
less
filename
Scroll through a content of a text file. Drücken q when done. „Less“
is roughly equivalent to „more“ , the Befehl 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 -w filename
Edit a text file, while disabling the long line wrap. Handy for editing
configuration dateien, e.g.
.
find / -name „filename„
Find the file called „filename“ on your dateienystem starting the search
from the root Verzeichnis „/“. The „filename“ may contain wildcards (*,?).
locate
filename
Find the file name of which contains the string „filename“. Easier
and faster than the previous Befehl but depends on a database that normally
rebuilds at night.
./program_name
Run an executable in the Aktuelle Verzeichnis, which is not on your PATH.
touch
filename
Ändert the date/time stamp of the file
to
the Aktuelle time. Erstellt an empty file if the file does not exist.
xinit
Start a barebone X-windows server (without a windows manager).
startx
Start an X-windows server and the default windows manager. Works like
typing „win“ under DOS with Win3.1
startx — :1
Start another X-windows session on the display 1 (the default is opened
on display 0). You can have several GUI terminals running conAktuellely.
Switch between them using <Ctrl><Alt><F7>, <Ctrl><Alt><F8>,
etc.
xterm
(in X terminal) Run a simple X-windows terminal. Typing
will close it. There are other, more advanced „virtual“ terminals
for X-windows. I like the popular ones:
and
(both come with kde) and
(comes with gnome).
If you need something really fancy-looking, try
.
xboing
(Im X terminal). Very nice, old-fashioned game. Many small games/programs
are probably installed on your system. I also like
(chess).
shutdown -h now
(Als root) Shut down the system to a halt. Mostly used for a remote
shutdown. Use <Ctrl><Alt><Del> for a shutdown at the console (which
can be done by any user).
halt
(Als root, zwei Befehle) Halt or reboot the machine. Used for remote
shutdown, simpler to type than the previous Befehl.
Network apps
(Im X terminal) Run netscape (requires a separate Netscape installation).
The Aktuelle versions of Netscape (4.x) are known to be big and buggy. They
occasionally crash by vanishing (no other harm done). Also, when not connected
to the network , Netscape likes to refuse to do anything (looks like it
hanged)-it revives when you connect.
netscape -display host:0.0
(in X terminal) Run netscape on the Aktuelle machine and direct the
output to machine named „host“ display 0 screen 0. Your Aktuelle machine
must have a Dateirechte to display on the machine „host“ (typically given
by executing the Befehl
|
xhost <em>Aktuelle_machine_name</em> |
in
the xterminal of the machine host. Other X-windows program can be run remotely
the same way.
lynx
file.html
Zeigt eine html Datei oder surft zur nexten webseite im Text mode.
pine
Ein gutes text-mode E-Mail Programm. Another good and standard one is
.
Your Netscape mail will read the mail from your Internet account.
will let you read the „local“ mail, e.g. the mail your son or a cron process
sends to you from a computer on your home network. The Befehl
could also be used for reading/composing mail, but it would be inconvenient–it
is meant to be used in scripts for automation.
elm
Ein gutes tex-mode Email Programm. In etwa wie das vorherige Programm.
mutt
A really basic but extremally useful and fast mail reader.
mail
A basic operating system tool for e-mail. Look at the previous Befehls
for a better e-mail reader.
is good if you wanted to send
an e-mail from a shell script.
licq
(in X term) An icq „instant messaging“ client. Another good one is
.
Older distributions don’t have an icq client installed, you have to do
download one and install it.
talk
username1
Talk to another user Aktuellely logged on your machine (or use „
|
talk <em>username1</em>@<em>machinename</em> |
“
to talk to a user on a different computer) . To accept the invitation to
the conversation, type the Befehl „
“. If
somebody is trying to talk to you and it disrupts your work, your may use
the Befehl „
“ to refuse accepting messages. You may want
to use „
“ or „
“ to determine the users who are
Aktuellely logged-in.
mc
Startet den „Midnight Commander“ Datei Manager (ist in etwa wie der bekannte „Norton commander“
für Windows).
telnet
server
Connect to another machine using the TELNET protocol. Use a remote
machine name or IP address. You will be prompted for your login name and
password–you must have an account on the remote machine to login. Telnet
will connect you to another machine and let you operate on it as if you
were sitting at its keyboard (almost). Telnet is not very secure–everything
you type goes in open text, even your password!
rlogin
server
(=remote login) Connect to another machine. The login name/password
from your Aktuelle session is used; if it fails you are prompted for a password.
rsh
server
(=remote shell) Yet another way to connect to a remote machine. The
login name/password from your Aktuelle session is used; if it fails you
are prompted for a password.
ftp
server
Ftp another machine. (There is also
which adds extra
features and
for GUI .) Ftp is good for copying dateien to/from
a remote machine. Try user „anonymous“ if you don’t have an account on
the remote server. After connection, use „?“ to see the list of available
ftp Befehls. The essential ftp Befehl are:
(see the
dateien on the remote system),
,
(set the file
transfer mode to either text or binary, important that you select the proper
one ),
(copy a file from the remote system to the local system),
(get many dateien at once),
(copy a file from the local system
to the remote system),
(put many dateien at once),
(disconnect). For automation in a script, you may want to use
and
, Beispielsweise:
|
ncftpput -u my_user_name -p my_password -a remote.host.domain remote_dir *local.html |
Minicom Programm (sieht in etwa aus wie „Procomm for Linux“).
Dateien Packen und Entpacken
|
tar -zxvf <em>filename.tar.gz</em> |
(=tape archiver) Untar a tarred packt einen tarball (*.tar.gz or
*.tgz) that you downloaded from the Internet.
tar -xvf filename.tar
Untar a tarred aber nicht gepackten tarball (*.tar).
gunzip
filename.gz
Entpackt eine gezippte Datei (*.gz“ or *.z). Use gzip (also
or
) if you wanted to comDrücken dateien to this file format.
bunzip2
filename.bz2
(=big unzip) Entpackt a file (*.bz2) zipped mit dem bzip2 Packprogramm
utility. Wird für größere Dateien verwendet
unzip
filename.zip
Entpackt eine Datei (*.zip) das gepackt ist mit einem Packprogramm das kompatibel ist
zu WINZIP für Windows.
unarj e filename.arj
Extract the content of an *.arj archive.
uudecode -o outputfile filename
Decode a file encoded with
. uu-encoded dateien
are typically used for transfer of non-text dateien in e-mail (uuencode transforms
any file into an ASCII file).
Prozesse in Linux
(=print status) Display the list of Aktuellely running
processes with their process IDs (PID) numbers. Use
to
see all processes Aktuellely running on your system (also those of other
users or without a controlling terminal), each with the name of the owner.
Use „top“ to keep listing the processes Aktuellely running.
fg
PID
Bring a background or stopped process to the foreground.
bg
PID
Send the process to the background. Opposite to fg. The same can be
accomplished with <Ctrl>z. If you have stopped jobs, you have
to type
twice in row to log out.
any_Befehl&
Run any Befehl in the background (the symbol „&“ means „run the
proceeding Befehl in the background“).
batch any_Befehl
Run any Befehl (usually one that is going to take more time) when
the system load is low. I can logout, and the process will keep running.
at 17:00
ausführen a Befehl at a specified time. You will be prompted for
the Befehl(s) to run, until you Drücken <Ctrl>d.
kill
PID
Force a process shutdown. First determine the PID of the process to
kill using ps.
killall
program_name
Kill program(s) by name.
xkill
(in an xwindow terminal) Kill a GUI-based program with mouse. (Point
with your mouse cursor at the window of the process you want to kill and
click.)
lpc
(Als root) Check and control the printer(s). Type „?“ to see the list
of available Befehls.
lpq
Show the content of the printer queue. Under KDE (X-Windows), you may
use GUI-based „Printer Queue“ available from „K“menu-Utilities.
lprm
job_number
Entfernt a printing job „job_number“ from the queue.
nice
program_name
Run
program_name adjusting its priority. Since the priority
is not specified in this example, it will be adjusted by 10 (the process
will run slower), from the default value (usually 0). The lower the number
(of „niceness“ to other users on the system), the higher the priority.
The priority value may be in the range -20 to 19. Only root may specify
negative values. Use „top“ to display the priorities of the running processes.
renice -1 PID
(Als root) Ändert the priority of a running process to -1. Normal users
can only adjust processes they own, and only up from the Aktuelle value
(make them run slower).
,
,
, and
also belong to this chapter but they were described previously.
In short they mean: stop the Aktuelle Befehl, send the Aktuelle Befehl
to the background, stop the data transfer, resume the data transfer.
Grundlegende Linux Administrations Befehle
(Als root Im X-Terminal) Configuration tool for your printer(s). Settings
go to the file
.
(Als root) Configure mouse, soundcard, keyboard, X-windows, system services.
There are many distibution-specific configuration utilities,
is the default on RedHat. Mandrake 7.0 offers very nice
.
linuxconfig
(Als root, either in text or graphical mode). You can access and Ändert
hundreds of setting from it. Very powerful–don’t Ändert too many things
at the same time, and be careful with changing entries you don’t understand.
xvidtune
(Im X-Terminal). Adjust the settings of the graphical display for all
resolutions so as to eliminate black bands, shift the display right/left/up/down,
etc. (First use the knobs on your monitor to fit your text mode correctly
on the screen.) To make the Änderts permanent, display the frequencies
on the screen and transfer them to the setup file
.
alias ls=“ls –color=tty“
Erstellt an alias for the Befehl „ls“ to enhance its format with color.
In this example, the alias is also called „ls“ and the „color“ option is
only envoke when the output is done to a terminal (not to dateien). Put the
alias into the file
if you would like the alias to
be always accessible to all users on the system. Type „
“
alone to see the list of aliases on your system.
adduser
user_name
Erstellt a new account (you must be root). E.g.,
Don’t forget to set up the password for the new user in the next step.
The user home Verzeichnis is
|
/home/<em>user_name</em>. |
useradd
user_name
Das selbe wie der Befehl “
|
adduser <em>user_name</em> " |
.
userdel
user_name
Löscht einen Account (funktioniert nur als root). The user’s home Verzeichnis and
the undelivered mail must be dealt with separately (manually because you
have to decide what to do with the dateien).
groupadd
group_name
Erstellt a new group on your system. Non-essential but can be handy even
on a home machine with a small number of users.
passwd
Ändert the password on your Aktuelle account. If you are root, you can
Ändert the password for any user using:
chmod perm filename
(=Dateirechte ändern) Ändert the file access Dateirechte for the dateien you
own (unless you are root in which case you can Ändert any file). You can
make a file accessible in three modes: read (r), write (w), ausführen (x)
to three classes of users: owner (u), members of the same group as the
owner (g), others on the system (o). Check the Aktuelle access Dateirechtes
using:
ls -l filename
If the file is accessible to all users in all modes it will show:
rwxrwxrwx
The first triplet shows the file Dateirechte for the owner of the file,
the second for his/her group, the third for others. A „no“ Dateirechte is
shown as „-„.
E.g., this Befehl will add
the Dateirechte to read the file
„junk“ to all (=user+group+others):
chmod a+r junk
Dieser Befehl will Entfernt the Dateirechte to ausführen the file junk from
others:
chmod o-x junk
You can set the default file Dateirechtes for the news dateien that you
Erstellt using the Befehl
(see
).
|
chown <em>new_ownername filename</em> |
|
chgrp <em>new_groupname filename</em> |
Ändert Dateibesitzer und die Gruppe. You should use these two Befehls
after you copy a file for use by somebody else.
(=substitute user id) Assume the superuser (=root) identity (you will
be prompted for the password). Type „exit“ to return you to your previous
login. Don’t habitually work on your machine Als root. The root account
is for administration and the su Befehl is to ease your access to the
administration account when you require it. You can also use „su“ to assume
any other user identity, e.g.
will make me „barbara“
(password required unless I am a superuser).
(Als root in X terminal). GUI to to add/Entfernt kernel modules. You can
do the same from the Befehl line using the Befehl „
“,
but „
“ is less „newbie-friendly“.
Listet die aktuellen geladenen Kernel Module auf. A module is like a device driver–it
provides operating system kernel support for a particular piece of hardware
or feature.
List all the modules available for your kernel. The available modules
are determined by how your Linux kernel was compliled. Every possible module/feature
can be compiled on linux as either „hard wired“ (fast, non-removable),
„module“ (maybe slower, but loaded/removable on demand), or „no“ (no support
for this feature at all).
insmod parport
(Als root) Insert modules into the kernel (a module is roughly an equivalent
of a DOS device driver). This example shows how to insert the modules for
support of the external parallel port zip drive (it appears to be a problem
to get the external zip drive to work in any other way under RH6.0
).
rmmod
module_name
(Als root). Entfernt the module module_name from
the kernel.
setserial /dev/cua0 port 0x03f8 irq 4
(Als root) Set a serial port to a non-standard setting. The example
here shows the standard setting for the first serial port (cua0 or ttyS0).
The standard PC settings for the second serial port (cua1or ttyS1) are:
address of i/o port 0x02f8, irq 3. The third serial port (cua2 or ttyS2):
0x03e8, irq 4. The forth serial port (cua3 or ttyS3): 0x02e8, irq 3. Add
your setting to
if you want it to be set at
the boot time. See man setserial for good a overview.
fdisk
(Als root) Linux hard drive partitioning utility (DOS has a utility
with the same name).
cd /usr/src/linux-2.0.36
(Als root in X terminal). Nice GUI front-end for configuration of the
kernel options in preparation for compilation of your customized kernel.
(The Verzeichnis name contains the version of your Linux kernel so you may
need to modify the Verzeichnis name if your Linux kernel version is different
than 2.0.36 used in this example. You also need the „Tk“ interpreter and
the kernel source code installed. ) The alternatives to „make xconfig“
are: „make config“ (runs a scripts that asks you questions in the
text mode) and „make menuconfig“ (runs a text-based menu-driven configuration
utility).
Try:
|
less /usr/doc/HOWTO/Kernel-HOWTO |
for more information.
After the configuration, you may choose to proceed with kernel
compilation of the new kernel by issuing the following Befehls:
make dep
The last Befehl will take some time to complete (maybe 0.5 h, depending
on your hardware). It produces the file „zImage“, which is your new Linux
kernel. Next:
Read: /usr/doc/HOWTO/Kernel-HOWTO for information on how to install
the new kernel. You will probably also find it useful to read „man depmode“.
Configuration, compilation and installation of a new kernel is not difficult
but it CAN lead to problems if you don’t know what you are doing.
Compilation of a kernel is a good way to test your hardware, because
it involves a massive amount of computing. If your hardware is „flaky“,
you will most likely receive the „signal 11“ error.
depmod -a
(Als root) Build the module dependency table for the kernel. This can,
Beispielsweise, be useful after installing and booting a new kernel. Use „
“ to load the modules.
ldconfig
(Als root) Re-Erstellt the bindings and the cache for the loader of dynamic
libraries („ld“). You may want to run ldconfig after an installation of
new dynamically linked libraries on your system. (It is also re-run every
time you boot the computer, so if you reboot you don’t have to run it manually.)
mknod /dev/fd0 b 2 0
(=make node, Als root) Erstellt a device file. This example shows how
to Erstellt a device file associated with your first floppy drive and could
be useful if you happened to accidentally erase it. The options are: b=block
mode device (c=character mode device, p=FIFO device, u=unbuffered character
mode device). The two integers specify the major and the minor device number.
(=floppy disk format, two Befehls, Als root) Perform a low-level formatting
of a floppy in the first floppy drive (/dev/fd0), high density (1440 kB).
Then make a Linux dateienystem (-t ext2), checking/marking bad blocks (-c
). Making the dateien system is an equivalent to the high-level format.
|
badblocks /dev/fd01440 1440 |
(Als root) Check a high-density floppy for bad blocks and display the
results on the screen. The parameter „1440“ specifies that 1440 blocks
are to be checked. This Befehl does not modify the floppy.
fsck -t ext2 /dev/hda2
(=file system check, als root) Check and repair a dateienystem. The example
uses the partition hda2, dateienystem type ext2.
dd if=/dev/fd0H1440 of=floppy_image
|
dd if=floppy_image of=/dev/fd0H1440 |
(Zwei Befehls, dd=“data duplicator“) Erstellt ein Image einer Diskette to
the file called „floppy_image“ in the Aktuelle Verzeichnis. Then copy
(file) to another floppy disk. Works like DOS „DISKCOPY“.
Programme unter Linux Installieren
|
rpm -ivh<em> filename.rpm</em> |
(=RedhatPackageManager, install, verbose, hashes displayed to show
progress, Als root.) Install a content of RedHat rpm package(s) and print
info on what happened. Keep reading if you prefer a GUI installation.
|
rpm -qpi <em>filename.rpm</em> |
(=RedhatPackageManager, query, package, list.) Read the info on the
content of a yet uninstalled package
filename.rpm.
|
rpm -qpl <em>filename.rpm</em> |
(=RedhatPackageManager, query, package, information.) List the dateien
contained in a yet uninstalled package
filename.rpm.
|
rpm -qf <em>filename</em> |
(=RedhatPackageManager, query, file.) Find out the name of the *.rpm
package to which the file
filename (on your hardrive) belongs.
|
rpm -e <em>packagename</em> |
(=RedhatPackageManager, erase=uninstall.) Uninstall a package pagckagename.
Packagname
is the same as the beginning of the *.rpm package file but without the
dash and version number.
kpackage
(Im X terminal, Als root if you want to be able to install packages)
GUI fronts to the Red Hat Package Manager (rpm). „glint“ comes with RH5.2,
„gnorpm“ with RH6.0, „kpackage“ comes with RH6.1 or must be installed separately
but is the best of the three. Use any of them to view which software packages
are installed on your system and the what not-yet-installed packages are
available on your RedHat CD, display the info about the packages, and install
them if you want (installation must be done Als root).
Zugriff auf Festplatten und Partitionen unter Linux
Mounting drives. Examples are shown in the next Befehls.
mount -t auto /dev/fd0 /mnt/floppy
(Als root) Mount the floppy. The Verzeichnis
must
exist, be empty and NOT be your Aktuelle Verzeichnis.
mount -t auto /dev/cdrom /mnt/cdrom
(Als root) Mount the CD. You may need to Erstellt/modify the
file depending where your CDROM is. The Verzeichnis
must
exist, be empty and NOT be your Aktuelle Verzeichnis.
mount /mnt/floppy
(as user or root) Mount a floppy as user. The file
must be set up to do this. The Verzeichnis
must not
be your Aktuelle Verzeichnis.
mount /mnt/cdrom
(as user or root) Mount a CD as user. The file
must be set up to do this. The Verzeichnis
must not be
your Aktuelle Verzeichnis.
umount /mnt/floppy
Unmount the floppy. The Verzeichnis
must not be
your (or anybody else’s) Aktuelle working Verzeichnis. Depending on your setup,
you might not be able to unmount a drive that you didn’t mount.
Network administration Tools
(Als root) A very good menu-driven setup of your network.
pingmachine_name
Check if you can contact another machine (give the machine’s name or
IP), Drücken <Ctrl>C when done (it keeps going).
route -n
Show the kernel routing table.
nslookup
host_to_find
Query your default domain name server (DNS) for an Internet name (or
IP number) host_to_find. This way you can check if your DNS works.
You can also find out the name of the host of which you only know the IP
number.
traceroute host_to_trace
Have a look how you messages trave to
(which is either a host name or IP number).
ipfwadm -F -p m
(for RH5.2, seen next Befehl for RH6.0) Set up the firewall IP forwarding
policy to masquerading. (Not very secure but simple.) Purpose: all computers
from your home network will appear to the outside world as one very busy
machine and, Beispielsweise, you will be allowed to browse the Internet from
all computers at once.
echo 1 > /proc/sys/net/ipv4/ip_forward
|
ipfwadm-wrapper -F -p deny |
|
ipfwadm-wrapper -F -a m -S xxx.xxx.xxx.0/24 -D 0.0.0.0/0 |
(Drei Befehls, RH6.0). Does the same as the previous Befehl. Substitute
the „x“s with digits of your class „C“ IP address that you assigned
to your home network. See here
for more details. In RH6.1, masquarading seems broken to me–I think I
will install Mandrake Linux:).
ifconfig
(Als root) Display info on the network interfaces Aktuellely active (ethernet, ppp, etc). Your first ethernet should show up as eth0, second
as eth1, etc, first ppp over modem as ppp0, second as ppp1, etc. The „lo“
is the „loopback only“ interface which should be always active. Use the
options (see
) to configure the interfaces.
ifup interface_name
(
to it run as a user) Startup a network interface.
E.g.:
Users can start up or shutdown the ppp interface only when the right
Dateirechte was checked during the ppp setup (using
).
To start a ppp interface (dial-up connection), I normally use kppp available
under kde menu „internet“.
ifdown
interface_name
(
to run it as a user). Shut down the network
interface. E.g.:
Also, see the previous Befehl.
netstat | more
Displays a lot (too much?) information on the status of your network.
Musik bezogene Linux Befehle
Play the first track from a audio CD.
eject
Eject the CD
ROM tray
play my_file.wav
Spielt eine wave Datei ab.
mpg123 my_file.mp3
Spielt eine mp3 Datei ab.
mpg123 -w my_file.wav my_file.mp3
Erstellt a wave audio file from an mp3 audio file.
knapster
(in X Terminal) Start the program to downolad mp3 dateien that other
users of napster have displayed for downloading. Really cool!
cdparanoia -B „1-„
(CD ripper) Read the contents of an audio CD and save it into
wavedateien in the Aktuelle directories, one track per wavefile. The
„1-„
means „from track 1 to the last“. -B forces putting each track into
a separate file.
playmidi my_file.mid
Spielt eine midi Datei ab.
|
playmidi -r <em>my_file.mid</em> |
will display text mode effects on the screen.
sox
(argument not given here) Convert from almost any audio file format
to another (but not mp3s). See
.
Graphik bezogene Linux Befehle
|
kghostview <em>my_file.ps</em> |
Zeigt eine postscript file auf dem Bildschirm. I can also use the older-looking
or
for the same end effect.
ps2pdf my_file.ps my_file.pdf
Erstellt eine pdf (Adobe portable document format) Datei aus einer postscript
Datei.
gimp
(in X terminal) A humble looking but very powerful image processor.
Takes some learning to use, but it is great for artists, there is almost
nothing you can’t do with gimp. Use your mouse right button to get local
menus, and learn how to use layers. Save your file in the native gimp file
format *.xcf (to preserve layers) and only then flatten it and save as
png (or whatever). There is a large user manual /usr/
gphoto
(in X terminal) Mächtiger Foto Editor.
giftopnm my_file.giff > my_file.pnm
|
pnmtopng <em>my_file.pnm</em> > <em>my_file.png</em> |
Convert the propriatory giff graphics into a raw, portable pnm file.
Then convert the pnm into a png file, which is a newer and better standard
for Internet pictures (better technically plus there is no danger
of being sued by the owner of giff patents).
#############
TCPView für Windows v3.05
http://technet.microsoft.com/de-de/sysinternals/bb897437
50 Most Frequently Used UNIX / Linux Commands (With Examples)
by Ramesh Natarajan on November 8, 2010
This article provides practical examples for 50 most frequently used commands in Linux / UNIX.
This is not a comprehensive list by any means, but this should give you a jumpstart on some of the common Linux commands. Bookmark this article for your future reference.
Did I miss any frequently used Linux commands? Leave a comment and let me know.
1. tar command examples
Create a new tar archive.
|
$ tar cvf archive_name.tar dirname/ |
Extract from an existing tar archive.
|
$ tar xvf archive_name.tar |
View an existing tar archive.
|
$ tar tvf archive_name.tar |
More tar examples: The Ultimate Tar Command Tutorial with 10 Practical Examples
2. grep command examples
Search for a given string in a file (case in-sensitive search).
|
$ grep -i "the" demo_file |
Print the matched line, along with the 3 lines after it.
|
$ grep -A 3 -i "example" demo_text |
Search for a given string in all files recursively
More grep examples: Get a Grip on the Grep! – 15 Practical Grep Command Examples
3. find command examples
Find files using file-name ( case in-sensitve find)
|
# find -iname "MyCProgram.c" |
Execute commands on files found by the find command
|
$ find -iname "MyCProgram.c" -exec md5sum {} ; |
Find all empty files in home directory
More find examples: Mommy, I found it! — 15 Practical Linux Find Command Examples
4. ssh command examples
Login to remote host
|
ssh -l jsmith remotehost.example.com |
Debug ssh client
|
ssh -v -l jsmith remotehost.example.com |
Display ssh client version
|
$ ssh -V OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003 |
More ssh examples: 5 Basic Linux SSH Client Commands
5. sed command examples
When you copy a DOS file to Unix, you could find rn in the end of each line. This example converts the DOS file format to Unix file format using sed command.
Print file content in reverse order
|
$ sed -n '1!G;h;$p' thegeekstuff.txt |
Add line number for all non-empty-lines in a file
|
$ sed '/./=' thegeekstuff.txt | sed 'N; s/n/ /' |
More sed examples: Advanced Sed Substitution Examples
6. awk command examples
Remove duplicate lines using awk
|
$ awk '!($0 in array) { array[$0]; print }' temp |
Print all lines from /etc/passwd that has the same uid and gid
|
$awk -F ':' '$3==$4' passwd.txt |
Print only specific field from a file.
|
$ awk '{print $2,$5;}' employee.txt |
More awk examples: 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR
7. vim command examples
Go to the 143rd line of file
Go to the first match of the specified
|
$ vim +/search-term filename.txt |
Open the file in read only mode.
More vim examples: How To Record and Play in Vim Editor
8. diff command examples
Ignore white space while comparing.
|
# diff -w name_list.txt name_list_new.txt 2c2,3 < John Doe --- > John M Doe > Jason Bourne |
More diff examples: Top 4 File Difference Tools on UNIX / Linux – Diff, Colordiff, Wdiff, Vimdiff
9. sort command examples
Sort a file in ascending order
Sort a file in descending order
Sort passwd file by 3rd field.
|
$ sort -t: -k 3n /etc/passwd | more |
10. export command examples
To view oracle related environment variables.
|
$ export | grep ORACLE declare -x ORACLE_BASE="/u01/app/oracle" declare -x ORACLE_HOME="/u01/app/oracle/product/10.2.0" declare -x ORACLE_SID="med" declare -x ORACLE_TERM="xterm" |
To export an environment variable:
|
$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0 |
11. xargs command examples
Copy all images to external hard-drive
|
# ls *.jpg | xargs -n1 -i cp {} /external-hard-drive/directory |
Search all jpg images in the system and archive it.
|
# find / -name *.jpg -type f -print | xargs tar -cvzf images.tar.gz |
Download all the URLs mentioned in the url-list.txt file
|
# cat url-list.txt | xargs wget –c |
12. ls command examples
Display filesize in human readable format (e.g. KB, MB etc.,)
|
$ ls -lh -rw-r----- 1 ramesh team-dev 8.9M Jun 12 15:27 arch-linux.txt.gz |
Order Files Based on Last Modified Time (In Reverse Order) Using ls -ltr
Visual Classification of Files With Special Characters Using ls -F
More ls examples: Unix LS Command: 15 Practical Examples
13. pwd command
pwd is Print working directory. What else can be said about the good old pwd who has been printing the current directory name for ages.
14. cd command examples
Use “cd -” to toggle between the last two directories
Use “shopt -s cdspell” to automatically correct mistyped directory names on cd
More cd examples: 6 Awesome Linux cd command Hacks
15. gzip command examples
To create a *.gz compressed file:
To uncompress a *.gz file:
Display compression ratio of the compressed file using gzip -l
|
$ gzip -l *.gz compressed uncompressed ratio uncompressed_name 23709 97975 75.8% asp-patch-rpms.txt |
16. bzip2 command examples
To create a *.bz2 compressed file:
To uncompress a *.bz2 file:
More bzip2 examples: BZ is Eazy! bzip2, bzgrep, bzcmp, bzdiff, bzcat, bzless, bzmore examples
17. unzip command examples
To extract a *.zip compressed file:
View the contents of *.zip file (Without unzipping it):
|
$ unzip -l jasper.zip Archive: jasper.zip Length Date Time Name -------- ---- ---- ---- 40995 11-30-98 23:50 META-INF/MANIFEST.MF 32169 08-25-98 21:07 classes_ 15964 08-25-98 21:07 classes_names 10542 08-25-98 21:07 classes_ncomp |
18. shutdown command examples
Shutdown the system and turn the power off immediately.
Shutdown the system after 10 minutes.
Reboot the system using shutdown command.
Force the filesystem check during reboot.
19. ftp command examples
Both ftp and secure ftp (sftp) has similar commands. To connect to a remote server and download multiple files, do the following.
|
$ ftp IP/hostname ftp> mget *.html |
To view the file names located on the remote server before downloading, mls ftp command as shown below.
|
ftp> mls *.html - /ftptest/features.html /ftptest/index.html /ftptest/othertools.html /ftptest/samplereport.html /ftptest/usage.html |
More ftp examples: FTP and SFTP Beginners Guide with 10 Examples
20. crontab command examples
View crontab entry for a specific user
Schedule a cron job every 10 minutes.
|
*/10 * * * * /home/ramesh/check-disk-space |
More crontab examples: Linux Crontab: 15 Awesome Cron Job Examples
21. service command examples
Service command is used to run the system V init scripts. i.e Instead of calling the scripts located in the /etc/init.d/ directory with their full path, you can use the service command.
Check the status of a service:
Check the status of all the services.
Restart a service.
22. ps command examples
ps command is used to display information about the processes that are running in the system.
While there are lot of arguments that could be passed to a ps command, following are some of the common ones.
To view current running processes.
To view current running processes in a tree structure. H option stands for process hierarchy.
23. free command examples
This command is used to display the free, used, swap memory available in the system.
Typical free command output. The output is displayed in bytes.
|
$ free total used free shared buffers cached Mem: 3566408 1580220 1986188 0 203988 902960 -/+ buffers/cache: 473272 3093136 Swap: 4000176 0 4000176 |
If you want to quickly check how many GB of RAM your system has use the -g option. -b option displays in bytes, -k in kilo bytes, -m in mega bytes.
|
$ free -g total used free shared buffers cached Mem: 3 1 1 0 0 0 -/+ buffers/cache: 0 2 Swap: 3 0 3 |
If you want to see a total memory ( including the swap), use the -t switch, which will display a total line as shown below.
|
ramesh@ramesh-laptop:~$ free -t total used free shared buffers cached Mem: 3566408 1592148 1974260 0 204260 912556 -/+ buffers/cache: 475332 3091076 Swap: 4000176 0 4000176 Total: 7566584 1592148 5974436 |
24. top command examples
top command displays the top processes in the system ( by default sorted by cpu usage ). To sort top output by any column, Press O (upper-case O) , which will display all the possible columns that you can sort by as shown below.
|
Current Sort Field: P for window 1:Def Select sort field via field letter, type any other key to return a: PID = Process Id v: nDRT = Dirty Pages count d: UID = User Id y: WCHAN = Sleeping in Function e: USER = User Name z: Flags = Task Flags ........ |
To displays only the processes that belong to a particular user use -u option. The following will show only the top processes that belongs to oracle user.
More top examples: Can You Top This? 15 Practical Linux Top Command Examples
25. df command examples
Displays the file system disk space usage. By default df -k displays output in bytes.
|
$ df -k Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 29530400 3233104 24797232 12% / /dev/sda2 120367992 50171596 64082060 44% /home |
df -h displays output in human readable form. i.e size will be displayed in GB’s.
|
ramesh@ramesh-laptop:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 29G 3.1G 24G 12% / /dev/sda2 115G 48G 62G 44% /home |
Use -T option to display what type of file system.
|
ramesh@ramesh-laptop:~$ df -T Filesystem Type 1K-blocks Used Available Use% Mounted on /dev/sda1 ext4 29530400 3233120 24797216 12% / /dev/sda2 ext4 120367992 50171596 64082060 44% /home |
26. kill command examples
Use kill command to terminate a process. First get the process id using ps -ef command, then use kill -9 to kill the running Linux process as shown below. You can also use killall, pkill, xkill to terminate a unix process.
|
$ ps -ef | grep vim ramesh 7243 7222 9 22:43 pts/2 00:00:00 vim $ kill -9 7243 |
More kill examples: 4 Ways to Kill a Process – kill, killall, pkill, xkill
27. rm command examples
Get confirmation before removing the file.
It is very useful while giving shell metacharacters in the file name argument.
Print the filename and get confirmation before removing the file.
Following example recursively removes all files and directories under the example directory. This also removes the example directory itself.
28. cp command examples
Copy file1 to file2 preserving the mode, ownership and timestamp.
Copy file1 to file2. if file2 exists prompt for confirmation before overwritting it.
29. mv command examples
Rename file1 to file2. if file2 exists prompt for confirmation before overwritting it.
Note: mv -f is just the opposite, which will overwrite file2 without prompting.
mv -v will print what is happening during file rename, which is useful while specifying shell metacharacters in the file name argument.
30. cat command examples
You can view multiple files at the same time. Following example prints the content of file1 followed by file2 to stdout.
While displaying the file, following cat -n command will prepend the line number to each line of the output.
|
$ cat -n /etc/logrotate.conf 1 /var/log/btmp { 2 missingok 3 monthly 4 create 0660 root utmp 5 rotate 1 6 } |
31. mount command examples
To mount a file system, you should first create a directory and mount it as shown below.
|
# mkdir /u01 # mount /dev/sdb1 /u01 |
You can also add this to the fstab for automatic mounting. i.e Anytime system is restarted, the filesystem will be mounted.
|
/dev/sdb1 /u01 ext2 defaults 0 2 |
32. chmod command examples
chmod command is used to change the permissions for a file or directory.
Give full access to user and group (i.e read, write and execute ) on a specific file.
Revoke all access for the group (i.e read, write and execute ) on a specific file.
Apply the file permissions recursively to all the files in the sub-directories.
|
$ chmod -R ug+rwx file.txt |
More chmod examples: 7 Chmod Command Examples for Beginners
33. chown command examples
chown command is used to change the owner and group of a file.
To change owner to oracle and group to db on a file. i.e Change both owner and group at the same time.
|
$ chown oracle:dba dbora.sh |
Use -R to change the ownership recursively.
|
$ chown -R oracle:dba /home/oracle |
34. passwd command examples
Change your password from command line using passwd. This will prompt for the old password followed by the new password.
Super user can use passwd command to reset others password. This will not prompt for current password of the user.
Remove password for a specific user. Root user can disable password for a specific user. Once the password is disabled, the user can login without entering the password.
35. mkdir command examples
Following example creates a directory called temp under your home directory.
Create nested directories using one mkdir command. If any of these directories exist already, it will not display any error. If any of these directories doesn’t exist, it will create them.
|
$ mkdir -p dir1/dir2/dir3/dir4/ |
36. ifconfig command examples
Use ifconfig command to view or configure a network interface on the Linux system.
View all the interfaces along with status.
Start or stop a specific interface using up and down command as shown below.
|
$ ifconfig eth0 up $ ifconfig eth0 down |
More ifconfig examples: Ifconfig: 7 Examples To Configure Network Interface
37. uname command examples
Uname command displays important information about the system such as — Kernel name, Host name, Kernel release number,
Processor type, etc.,
Sample uname output from a Ubuntu laptop is shown below.
|
$ uname -a Linux john-laptop 2.6.32-24-generic #41-Ubuntu SMP Thu Aug 19 01:12:52 UTC 2010 i686 GNU/Linux |
38. whereis command examples
When you want to find out where a specific Unix command exists (for example, where does ls command exists?), you can execute the following command.
|
$ whereis ls ls: /bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz |
When you want to search an executable from a path other than the whereis default path, you can use -B option and give path as argument to it. This searches for the executable lsmk in the /tmp directory, and displays it, if it is available.
|
$ whereis -u -B /tmp -f lsmk lsmk: /tmp/lsmk |
39. whatis command examples
Whatis command displays a single line description about a command.
|
$ whatis ls ls (1) - list directory contents $ whatis ifconfig ifconfig (8) - configure a network interface |
40. locate command examples
Using locate command you can quickly search for the location of a specific file (or group of files). Locate command uses the database created by updatedb.
The example below shows all files in the system that contains the word crontab in it.
|
$ locate crontab /etc/anacrontab /etc/crontab /usr/bin/crontab /usr/share/doc/cron/examples/crontab2english.pl.gz /usr/share/man/man1/crontab.1.gz /usr/share/man/man5/anacrontab.5.gz /usr/share/man/man5/crontab.5.gz /usr/share/vim/vim72/syntax/crontab.vim |
41. man command examples
Display the man page of a specific command.
When a man page for a command is located under more than one section, you can view the man page for that command from a specific section as shown below.
|
$ man SECTION-NUMBER commandname |
Following 8 sections are available in the man page.
- General commands
- System calls
- C library functions
- Special files (usually devices, those found in /dev) and drivers
- File formats and conventions
- Games and screensavers
- Miscellaneous
- System administration commands and daemons
For example, when you do whatis crontab, you’ll notice that crontab has two man pages (section 1 and section 5). To view section 5 of crontab man page, do the following.
|
$ whatis crontab crontab (1) - maintain crontab files for individual users (V3) crontab (5) - tables for driving cron $ man 5 crontab |
42. tail command examples
Print the last 10 lines of a file by default.
Print N number of lines from the file named filename.txt
View the content of the file in real time using tail -f. This is useful to view the log files, that keeps growing. The command can be terminated using CTRL-C.
More tail examples: 3 Methods To View tail -f output of Multiple Log Files in One Terminal
43. less command examples
less is very efficient while viewing huge log files, as it doesn’t need to load the full file while opening.
One you open a file using less command, following two keys are very helpful.
|
CTRL+F – forward one window CTRL+B – backward one window |
More less examples: Unix Less Command: 10 Tips for Effective Navigation
44. su command examples
Switch to a different user account using su command. Super user can switch to any other user without entering their password.
Execute a single command from a different account name. In the following example, john can execute the ls command as raj username. Once the command is executed, it will come back to john’s account.
|
[john@dev-server]$ su - raj -c 'ls' [john@dev-server]$ |
Login to a specified user account, and execute the specified shell instead of the default shell.
|
$ su -s 'SHELLNAME' USERNAME |
45. mysql command examples
mysql is probably the most widely used open source database on Linux. Even if you don’t run a mysql database on your server, you might end-up using the mysql command ( client ) to connect to a mysql database running on the remote server.
To connect to a remote mysql database. This will prompt for a password.
|
$ mysql -u root -p -h 192.168.1.2 |
To connect to a local mysql database.
If you want to specify the mysql root password in the command line itself, enter it immediately after -p (without any space).
46. yum command examples
To install apache using yum.
To upgrade apache using yum.
To uninstall/remove apache using yum.
47. rpm command examples
To install apache using rpm.
|
# rpm -ivh httpd-2.2.3-22.0.1.el5.i386.rpm |
To upgrade apache using rpm.
|
# rpm -uvh httpd-2.2.3-22.0.1.el5.i386.rpm |
To uninstall/remove apache using rpm.
More rpm examples: RPM Command: 15 Examples to Install, Uninstall, Upgrade, Query RPM Packages
48. ping command examples
Ping a remote host by sending only 5 packets.
More ping examples: Ping Tutorial: 15 Effective Ping Command Examples
49. date command examples
Set the system date:
|
# date -s "01/31/2010 23:59:53" |
Once you’ve changed the system date, you should syncronize the hardware clock with the system date as shown below.
|
# hwclock –systohc # hwclock --systohc –utc |
50. wget command examples
The quick and effective method to download software, music, video from internet is using wget command.
|
$ wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.1.tar.gz |
Download and store it with a different name.
|
$ wget -O taglist.zip http://www.vim.org/scripts/download_script.php?src_id=7701 |
More wget examples: The Ultimate Wget Download Guide With 15 Awesome Examples
Did I miss any frequently used Linux commands? Leave a comment and let me know.

Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the
Linux Sysadmin Course Now!
If you enjoyed this article, you might also like..
1 person likes this