Benutzer-Werkzeuge

Webseiten-Werkzeuge


becki:linux:commands

Useful Linux Commands

Abstact

Short descriptions, hints and pointers to further information for useful linux commands.

This page started as an unordered collection of notes in a text file in german language and is now transfered slowly in a (hopefully) more organized english version.

Development Tools

Eg, make and gcc see Build Tools

Perl

The CPAN FAQ may be a starting point for installing modules. man CPAN or the same online may also help.

perl -M<module::name> -e 1 – Test if a module is already on the system Source: man perlmodinstall or same online

Date and Time

Systemzeit einstellen wenn grob verstellt

  • System- und Bios-Zeitzone einstellen mit timeconfig
  • Systemzeit einstellen mit date MMDDhhmm[[CC]YY][.ss]
  • /etc/adjtime löschen
  • hwclock --systohc --utc ist optional, wird beim runterfahren automatisch erledigt

Abweichung der Systemzeit nachregulieren

  • Systemzeit einstellen wie oben
  • hwclock --systohc ist optional, wird beim runterfahren automatisch erledigt

Old

date - zeigt die Systemzeit
date +%j --date=2004-03-08 - Tag-Nummer vom 2004-03-08 anzeigen
date --date=yesterday - gestriges Datum anzeigen
date +%j - Tag des Jahres
hwclock --utc --set --date="11/23/02 08:43:00"
  Errechnet aus der übergeben LocalTime die UTC und schreibt sie ins Bios
hwclock --show (--systohc)
  zeigt (& setzt) die Hardwarezeit
  Achtung systohc ändert /etc/adjtime

Users and Groups

Manuals

man

apropos
whatis
man -k 'stichwort' - suchen in den man pages (= apropos, siehe man man)
man 7 regex - Beschreibung der Posix Regular Expressions (aus Php Manual)

info

l - last page
u - one level up
i - search in index
s word - search hole file for word (s RET: search next)
khelpcenter - Kde-eigene Hilfe
yelp - Gnome-eigene Hilfe

Filesystem Tools

chmod

u+s set-user-ID bit: Set the process's effective user ID to that of the file upon execution
g+s set-group-ID bit: For directories, give files created in the directory the same group as the directory, no matter what group the user who creates them is in, and set the set-group-ID bit of newly-created subdirectories
+t Prevent unprivileged users from removing or renaming a file in a directory unless they own the file or the directory
+X execute permission is affected only if the file is a directory or already had execute permission

More

TextTools

cat

  • -n, –number - number all output lines
  • -A, –show-all - show whitepsace

diff

vim

Copy and Paste

Whithin Vim
  • Select text with mose and left mose button
  • Press y
  • Reposition cursor to desired place in text
  • Press p
From different Application
  • Select text with mose and left mose button in the other application
  • In Vim reposition cursor to desired place in text
  • Press i to for insert mode
  • Press shift + middle mose button

Old

dd - delete line
i - switch to insert mode
ESC - leave insert mode
STRG-AltGr-] - follow a link in the help system
STRG-t - jump back in the help system
A - append text at the end of the line
o - open a new line below the current line, append text

sed

General Options

-i modifies the file directly, result is not written to stdout

Select lines

sed -n '4p' file    # print only line 5 of file file
sed -n '2,4p' file  # print lines 2-4
sed -n '2,4!p' file # print all lines except lines 2-4

Source

Search and replace

sed 's/regexp/replacement/' file.txt
sed '2s/regexp/replacement/g' file.txt # only for line 2
sed '1,20s/regexp/replacement/g' file.txt # only for lines 1-20
sed '1,20!s/regexp/replacement/g' file.txt # all lines except lines 1-20

Source

cut

cut -c14-16 file

Print only characters 14 through 16 of all lines of file file. Source

less

  • -S kein Zeilenumbruch
  • -i --ignore-case
    Ignore case in searches that do not contain uppercase.
  • -I --IGNORE-CASE
    Ignore case in all searches.
  • :n - Examine the (N-th) next file from the command line.
  • :p - Examine the (N-th) previous file from the command line.

iconv (, recode)

Umwandlung von Textdateien in alle möglichen Kodierungsarten, auch sowas wie html-Formatierung, auch in php vorhanden, iconv ist besser!
iconv -f ISO-8859-1 -t UTF-8 file.txt > newfile.txt

Concat pdf files

pdfunite from the poppler lib

Alternatives: pdfconcat and gs:

gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=GoCourse.pdf GoCourseDay1.pdf GoCourseDay2.pdf GoCourseDay3.pdf

gs Source

Other

split -b bytes datei
  Große datei in 'bytes' große Stücke zerlegen. Funzt auch mit Binärdateien. Stücke lassen sich mit cat wieder zusammenflicken
fmt -s [-w 75] file.txt
  Überlange Zeilen umbrechen (line break, format, umbruch) unter Beibehaltung von Einrückungen
  -s: Neue Zeilen werden beibehalten (no refill)
  -w: maximum line width (default of 75 columns)
strings - useful for determining the contents of non-text files.
echo -e "$stringWithNewlines" - prints the \n's
sort - sort lines of text files
  -n nach Zahlen am Anfang sortieren (oder -g , info coreutils sort)
  -r reverse the result of comparisons

Rpm

rpm -e [--test] [-vv] gphoto
  Paket 'gphoto' [probehalber] [mit ausfühlichster Anzeige] deinstallieren
rpm -qf /pfad/datei
  zeige das Paket, daß die Datei /pfad/datei enthält
rpm -qa
  alle installierten Pakete auflisten
rpm -qi mysql
  Ausführliche Paketinformationen
rpm -ql mysql
  alle Dateien zum installierten Paket mysql anzeigen
rpm -qd mysql
  alle Dokumentations-Dateien zum installierten Paket mysql anzeigen
rpm -qc mysql
  alle Konfigurations-Dateien zum installierten Paket mysql anzeigen
rpm -q...p datei.rpm
  Abfrage der (noch) nicht intallierten Datei datei.rpm
rpm -ivh (--test) datei.rpm
  (Probehalber) Installation -v: verbose, -h: Fortschrittsbalken
rpm -Fvh (--test) datei.rpm
  Upgrade nur, wenn schon eine ältere Version existiert

Graphics Processing

rsync (Backup)

rsync must be installed on both the source and destination machines.

Useful Options

-a, –archive archive mode, equivalent to -rlptgoD
-D same as –devices –specials
-e ssh specify the remote shell to use
-g, –group preserve group
-H, –hard-links preserve hard links
-l, –links copy symlinks as symlinks
-n, –dry-run show what would have been transferred
-o, –owner preserve owner (root only)
-p, –perms preserve permissions
-P same as –partial –progress
-r, –recursive recurse into directories
-S, –sparse handle sparse files efficiently
-t, –times preserve times
-v, –verbose increase verbosity
-z, –compress compress file data
–delete delete files that don't exist on the sending side
–devices preserve device files (super-user only)
–progress show progress during transfer
–partial keep partially transferred files
–specials preserve special files
–stats give some file transfer stats

Examples

rsync -aPSHe ssh lfile ruser@rhost:rdir  # copy lfile in local working directory into rdir in home dir on host
rsync -aPSHe ssh lfile ruser@rhost:/rdir # copy lfile in local working directory into rdir in root dir on host
 
rsync -aPSHe ssh ldir  ruser@rhost:rdir  # recursively copy ldir into rdir
rsync -aPSHe ssh ldir/ ruser@rhost:rdir  # recursively copy the contents of ldir into rdir
 
rsync -aPSHe ssh ruser@rhost:rdir  ldir  # recursively copy remote rdir into local ldir
rsync -aPSHe ssh ruser@rhost:rdir/ ldir  # recursively copy the contents of remote rdir into local ldir

Opts from http://mirrors.slackware.com/guidelines/

Compression and Archives

jar -tf file.jar - Inhalt von file.jar angucken
jar -xf file.jar - Inhalt von file.jar extrahieren
tar -xjf [pfad/]datei.tar.bz2
  mit bzip2 komprimiertes tar-Archiv extrahieren; bzip2 komprimiert offensichtlich besser als zip
tar -tzf [pfad/]datei.tgz
  gezipptes tar-Archiv einsehen
tar -czf [pfad/]datei.tgz datei1 datei2
  gezipptes tar-Archiv datei.tgz mit den Dateien datei1 datei2 erzeugen
tar -xzf [pfad/]datei.tgz
  mit gzip gezipptes tar-Archiv extrahieren
  Am günstigsten startet man diesen Befehl vom Zielverzeichnis aus, dann spart man sich das kopieren der Archivdatei
gzip, gunzip
  .gz - Files packen & entpacken (wird von tar verwendet)
zip -r archiv verz
  Verzeichnis 'verz' recursiv komprimieren in die Datei archiv.zip (pkzip-kompatibel)
unzip archiv[.zip]
  Datei archiv.zip extrahieren in aktuelles Verzeichnis
unzip -l archiv[.zip]
  Inhalt von archiv.zip einsehen
unzip -c archiv.zip pfadImArchiv/eineArchivDatei
  Inhalt der 'eineArchivDatei' aus archiv.zip auf stdout
file-roller - Gnome Archiver Gui
ark - KDE Archiver Gui

Mounten, Partitionieren & Formatieren

'man fs' gibt eine Übersicht über die verschiedenen Filesysteme, v.a. die dos-Typen

Partitionieren

  • fdisk -l - Übersicht Partitionierung aller Platten
  • cfdisk -P s /dev/xxx - Übersicht Partitionierung einer Platte
    fdisk -l scheint jedoch besser

SD & USB Drives

mount /dev/hde1 /media/flash - mountet eine pcmcia-flash-card ans Verzeichnis /media/flash

fuser - identify processes using files or sockets (nützlich beim unmounten)

/var/log/messages gives you the name of the device file which is necessary to mount and format the memory stick. Typical is /dev/sda1 or /dev/sdab

VFAT Formatting

VFAT is the default file system on off the shelf memory sticks, PC- and SD-cards. Use it if you need compatibility with M$-Windows.

mkfs.vfat -v [-c] [-n volume-name] /dev/hde1 - Formats a PCMCIA-card or sdcard or USB-stick with msdos-FS

mkdosfs, mkfs.vfat and mkfs.msdos are symlinks for mkfs.fat

Also

Entry in fstab für vfat-formatted sticks - no necessary any more:

/dev/sda1  /mnt/ums  vfat  noauto,user  0  0 #or
/dev/sda1  /mnt/ums  auto  noauto,user  0  0

An off the shelf memory stick has a file system type ID of 6 (= FAT16). See fdisk -l

Also helpful: slackware-14.1/usb-and-pxe-installers/README_USB.TXT

VFAT Renaming

Use dosfslabel (only uppercase possible)

You can rename e.g. a label in lowercase with mtools:

  1. Plug USB stick into computer and mount it if necessary
  2. Type mount to see on which device the stick got mounted, this may be something like /dev/sdb1
  3. Unmount USB stick
  4. Open /etc/mtools.conf and change the line drive a: file=„/dev/fd0“ exclusive to the device where the stick got mounted, e.g. drive a: file=„/dev/sdb1“ exclusive
  5. Edit your personal mtools config file: echo 'mtools_skip_check=1' >> ~/.mtoolsrc
  6. Rename the stick: mtools a: and enter desired volume label

Linux Formatting

Linux file systems like ext3, ext4 and reiserfs are aware of the Linux protections modes (owner, group, etc.). Use it if you want exchange files between two Linus systems.

Example formatting for /dev/sdb1:

  1. Set the file system typ to 83 (= Linux) with cfdisk /dev/sdb1.
    (It may as well work without this step, but setting the right FS ID cannot harm.)
  2. Format the stick with: mkfs.ext3 -L BeckisStick /dev/sdb1

Sole renaming the disk label is possible with: e2label device new-label. Source: https://linuxconfig.org/how-to-name-label-a-partition-or-volume-on-linux

Floppies

fdformat /dev/fd0
  formatiert eine Diskette low level, macht offensichtlich noch kein Dateisystem
mkdosfs -v -c /dev/fd0
  formatiert eine Diskette mit FAT (8.3 Format, siehe auch man fs)
  -v verbose, -c vorher überprüfen,
  bei Slack muß man offensichtlich der Gruppe floppy zugehören (ll /dev/fd0)
  Slack-Symlink: mkfs.msdos -> mkdosfs
badblocks /dev/fd0
  Checkt eine Partition (auch Diskette) auf Fehler, die badblocks werden auf stdout geschrieben
dosfsck /dev/fd0 - check and repair MS-DOS file systems

Misk

mkreiserfs
  Symlink: mkfs.reiserfs -> mkreiserfs
  
reiserfstune --label labelname /dev/XXX
  Change the volume name of a Reiser filsystem without destroying data
fsck.????
  Dateisystemcheck
  man fs zeigt die vorhandenen Filesystemtypen

XML

xmlwf - non-validating xml parser
xmllint - xml parser

Drucken

lpr datei.txt
  Druckt die Datei (Formatierungsoptionen nötig)
  Slack 9.0:        /usr/bin/lp -> lpr
  Slack 9.1 & 10.0: /usr/bin/lp -> lp-lprng (lpr-cups)
                                /usr/bin/lpr -> lpr-lprng (lpr-cups)
lpq - zeigt alle Aufträge in der Standard Druckwarteschlange
  1. lprm all - löscht alle Aufträge aus der Standard Druckwarteschlange

Sound

Terminal-Emulatoren

Gnu Screen Tips

mrxvt - with transparency and tabs
rxvt - Ressoucensparender Terminalemulator (Subset von xterm)
aterm - baut auf rxvt auf, unterstützt Transparenz
~/.Xdefaults Beispiel:
  XTerm*loginShell: true
  XTerm*geomtery:   80*48
  XTerm*visualBell: true
  Aterm*scrollBar: false
  Aterm*transparent: true

Burn Cds

Daten-Cds ließt man aus mit dd (Linux-User) oder besser mit readcd (CD-Writing-HOWTO). Brennen kann man sie dann mit cdrecord.

Audio-Cds muß man auslesen mit cdda2wav (man cdrecord: „To copy an audio CD…“) oder besser cdparanoia (CD-Writing-HOWTO. Brennen geht auch wieder mit cdrecord (man cdrecord)

FIXME Was ist mit SVCDs? Bisher immer cdrdao verwendet. Hier entstehen möglicherweise Qualitätsverluste (Tini's DVD-Player hatte Probleme mit den Kopien). Oder lag das an meinem alten Brenner? Wie sieht der Aufbau einer SVCD aus? ist das eine Daten-Cd oder eine Audio-CD? — 2006-08-30 16:17

Cdrtools

See Command line CD burning for cdrecord setup.

readcd [dev=0.0.0] f=cd.iso - read content of a CD and createt an ISO file from it

(CDR_DEVICE should be set in /etc/default/cdrecord)
FIXME Is readcd a better alternative as cdrdao for copying of CDs? xcdroast oviously uses this command (see xcdroast -v 1)

mkisofs -r -J -o cd.iso inDir/ - Create the file cd.iso with ISO9660 filesystem form the content of inDir/ (for later burning)

-r:Rockridge-Extensions für Unix
-J:Joliet Extensions für Windows
-o datei: Output-datei
see also: http://www.linux-user.de/ausgabe/2001/05/015-cdrecord/cdrecord.html

mount cd.iso /mnt/test -o loop - Mount the ISO image which was created with readcd or mkisofs for testing purposes

cdrecord -v [-dummy] [-nofix] [dev=0,0,0] [speed=4] cd.iso - burn cd.iso on a CD

-v: verbose (important, otherwise nothing can be seen during burning);
Default values for dev & speed should be set in /etc/default/cdrecord. According to the manpage there is no ~/.cdrecord file

cdrdao

cdrdao copy [–speed 8] [–device 0,0,0 –driver generic-mmc] Eine CD kopieren, d.h einlesen & anschließend brennen (SVCD, auch CDDA?)
Es geht auch in 2 Schritten: „read-cd mytoc“ & dann „write mytoc“ 2004-08-05 21:54 funzt nicht mit aktuellem /etc/cdrdao.conf
device von „cdrecord -scanbus“; Angabe von „–device 0,0,0 –driver generic-mmc“ generell nur nötig, wenn per –save noch keine Konfigurationsdatei erstellt wurde (man cdrdao)

cdrdao read-cd [–eject] mytoc - Inhalt einer CD auf Festplatte einlesen.

cdrdao write [–speed 8] [–eject] mytoc - Vorher mit read-cd eingelesene Kopie auf Rohling brennen
–eject oeffnet LW wenn fertig

cdrdao disk-info [–device 0,0,0] [–driver generic-mmc] Ließt Infos der CD ein, geht auch zum erstellen einer Konfig-datei mit –save

Konfigdateien

  • /etc/cdrdao.conf
  • $HOME/.cdrdao

Rip DVDs

OpenPGP

See OpenPGP

Networking

nmap

Port scanner and network exploration tool. See Beginners guide to nmapNmap Network Probing CheatsheetManpage10 Practical Examples Of Linux ‘nmap’ Command

-A Enables OS detection (-O) and Version detection (-sV), Script scanning and Traceroute
-p- scan all ports (1-65535) As default only interesting ports are scanned
-O Enable OS detection, included by -A
-sV Service and version detection, included by -A
–allports Only for Service detection (-sV): Don't exclude any ports, also ports which would wast paper on printers for example

netstat

netstat displays a list of open sockets (and more)

ss seems to be a newer alternative to nestat. See
https://unix.stackexchange.com/questions/106561/finding-the-pid-of-the-process-using-a-specific-port#106562

nc (netcat)

Howto copy directory trees with netcat

On the receiving side: nc -lv -p 5555 | tar - vxzf -

On the sending side: tar - vczf - directoryToBeSent | nc -v -q 9 targetHostName 5555

Notes:

  • The command on the receiving side has to be issued first
  • -q 9 termitates connection after EOF (seems as any number could be used instead of 9).
  • This mehtod works better than scp, because I didn't find a way to preserve symlinks with scp (like cp -a) so far.

ssh

Replaces rlogin and rsh, and provides secure encrypted communications between two untrusted hosts over an insecure network.

See also: SSH: Tips And Tricks You Need

Howto copy files and directory trees with ssh

With scp

scp -rp 030809Ibiza/ ilse:fotos/ secure remote file copy programm over ssh with scp command

With ssh

Alternatively, if scp is not available, a single files and dirs can be copied directly with ssh:

ssh user@host "cat > targetfile" < sourcefile # copies a single file from client to server
ssh user@host "cat sourcefile" > targetfile   # copies a single file from server to client

The following command copies a whole directory tree under /home/becki from the server to the client. It extracts the tree in the current local directory. This means, if you want to have the copied data in the same path as on the server, you have to cd to '/' (root directory) before you issue the command:

ssh [user@]host "tar -cf - /home/becki" | tar -xf -

FIXME verify: Copy a directory tree from client to server:

tar -cf - /path/to/local/sourcedir | ssh user@host "tar -xf - /path/to/remote/targetdir"

ssh without login

  • ssh-keygen (older versions: ssh-keygen -t rsa) generates private and public keys in homedir of client for client & server (omit passphrase!).
  • Add the content of the file ~/.ssh/id_rsa.pub from the client to the file ~/.ssh/authorized_keys on the server.
  • (If necessary create ~/.ssh/config with „Protocol 2“ in it.)
  • Then never use password again :-)

SSH tunneling for secure web surfing

#!/bin/bash
 
ssh -D 1080 -C -N -v $vserver
 
# Firefox config:
#   Activate "Manual Proxy Configuration"
#   Socks Host: 127.0.0.1 / Socks Port: 1080
#   No further entries in "Manual Proxy Configuration" Especially:
#     Empty HTTP Proxy / Port 0
#     Do NOT activate "Use this proxy server for all protocolls"
#  No proxy for: localhost, 127.0.0.1 etc

Source

sshfs

mounting:

sshfs [user@]host:[dir] mountpoint [options]

unmounting:

fusermount -u mountpoint

Old

rsh - can execute (one) command on romote host (no login)
rlogin - predecessor of telnet?

ssh -X hostname /path/to/program starts graphical program on remote host and display it locally (see also xhost)

curl

Configuration

Config file is ~/.curlrc. (Proxy) config example:

# PROXY AUTHENTICATION METHOD:
proxy-ntlm
#proxy-anyauth
 
# PROXY USER AND URL:
proxy-user = "user:pass"
proxy = "proxyhost:proxyport"

Usage

Download a single file:

curl -O http://www.gnu.org/favicon.ico
# or:
curl http://www.gnu.org/favicon.ico > favicon.ico

wget

Manual (better than man wget)

Options

  -r --recursive - Turn on recursive retrieving.
  -l --level=depth - Specify recursion maximum depth level. default=5
  -m --mirror - Equivalent to -r -N -l inf --no-remove-listing
  -k --convert-links - convert absolute links to relative links
  -E --html-extension - *.php, *.jsp -> *.html;
  -p --page-requisites - (only necessary if -l != inf)
  -np --no-parent
  -N --timestamping - Turn on time-stamping
  -nd - no dirs
  -x - force dirs
  --referer=<url>
  -U - user agent
  --user=user - username for  FTP and HTTP
  --password=password - password for  FTP and HTTP

Examples

Download a subdirectory of a remote server and make it suitable for local viewing without local webserver. -r is prefered over -m becaus -m does not seem to respect -np:

wget -r -k -E -np <url>

Old

Achtung möglicherweise funzt wget nicht richtig, wenn man die einbuchstabigen Optionen direkt aneinander hängt.
wget -p seite.html
  seite.html komplett mit allem Zubehör runterladen
wget -k -r -l 2 --no-parent URL
  'URL' recursiv (-r) runterladen & absolute Links in relative umwandeln (-k), sodaß man alles offline anschauen kann
wget -r -l 1 --no-parent -A.jpg URL
  nur *.jpg Dateien runterladen (index.html ist auch dabei)

Misc

hostname -f - eigenen Host- & Domainnamen anzeigen

nslookup (deprecated, Consider using the `dig' or `host' programs instead)
host - IpAdresse ↔ Hostname über DNS

tcpdump - kann Passwörter mitlesen (LinuxUser 04/04 S.38)
iptraf - Interactive Colorful IP LAN Monitor
netwatch - monitor activity on the network

mtr - kombiniert ping & traceroute (LinuxUser 04/04 S.38)
traceroute - Routen von Paketen über TCP/IP-Netzwerk anzeigen

ifconfig
route [-n]
ip - vereinigt ifconfig & route (LinuxUser 04/04 S.38 and http://www.tty1.net/blog/2010/ifconfig-ip-comparison_en.html)

brctl delbr <networkinterface> - remove an network interface (ifconfig <networkinterface> down only disables it)

netstat [-i] - Infos zum Netzwerk
netstat -an - Zeigt offene Ports! (von Grabsch)

arping - ping over arp protocol, see also linux.com article

System Commands

Power Management

library dependencies

  ldd - print shared library dependencies
    siehe Usenet: Alan Hicks: Re: What is a package mgr: swaret, slap-get, etc.
  ldconfig - configure dynamic linker run time bindings
  nm - list symbols from object files, from Program-Library-HOWTO

runlevel

poweroff - = telinit 0 (?)
shutdown -c - Cancel an already running shutdown.
runlevel - find the current and previous system runlevel
telinit 1 - go single user mode, administrative state (rc.K)
telinit 3 - go Muliuser mit Netz ohne Grafik (see /etc/inittab: [[important_files_and_directories#etc|Important Files and Directories]])
telinit 4 - go Full Multiuser with Network and xdm
  Quelle Slackware/UPGRADE.TXT
reboot

Power Management

  hdparm -S time /dev/hda - Set the standby (spindown) timeout for  the  drive
  hdparm -C /dev/hda - Check the current IDE power mode status
  apm - query Advanced Power Management
  apm -s, --suspend - Put the machine into suspend mode if possible.
  apm -S, --standby - Put the machine into standby mode if possible.

at & cron

  at, batch, atq, atrm - queue, examine or delete jobs for later execution
  crontab -l  - list crontab for user
  crontab -e  - edit crontab for user
    2004-11-26 19:54 hat nicht gefunzt auf ilse/slack10, keine Ahnung warum
  crontab crontabfile  -  replace crontab with crontabfile
    Achtung: Das Slackware crontab erkennt die 7 für Sonntag offensichtlich NICHT an => 0 benutzen!

Misc

  • sensors - print (temprerature) sensors information
  • lsof - list open files for file recovery, see article at linux.com
  • last - show listing of last logged in users
  • kernelversion - program to report major version of kernel
  • lsmod - listet alle gerade geladenen Kernelmodule auf
  • cardctl ident - Zeigt die PCMCIA-Informationen
  • lspci -vv oder -vt - list all PCI devices (gut!)
  • sudo - execute a command as another user. See also: How to add users to /etc/sudoers and sudoers file explained
  • uname -a - Systeminformationen, auch Kernelversion anzeigen

See also: Lazy Linux: 10 essential tricks for admins

Slack-spezifisch

  • rpm2tgz - Rpm-Paket in ein per installpkg installierbares Slack-Paket umwandeln; von www.slackbook.org
  • timeconfig - Wählen der Zeitsone und ob Bios-Uhr auf local oder UTC steht.
    Setzt /etc/hardwarcolock und /etc/localtime
  • netconfig - Änderungen nach setup sind damit möglich. Afterwards restart netowork with rc.inet1 resteart
  • liloconfig - Änderungen nach setup sind damit möglich
  • makebootdisk - SW-script to create system boot floppies.
  • pppsetup - Setup modem connection

xwmconfig

Erzeugt ein ~/.xinitrc, das von startx aufgerufen wird & einen bestimmten Windowmanger startet.
Wenn als root aufgerufen wirkt sich das auf den Systemstandard aus(?).
Quelle: [5]

Checkinstall

Not supported any more!

Overview

Help in /usr/doc/checkinstall-1.5.3/README, (README.1st). No manpage. Seems to run well without any options for Slack. For quick & dirty packages just follow these steps: ./configure; make; crate the „doc-pak“ directory; # checkinstall

Description

  • :!: Remove the old package: # removepkg oldPackage
  • Extract source tarball as normal user (untarring as root produced weird permissions for dirs on Slack 11.0)
  • Become root and recursively change owner/group to root, eg: # chown -R root:root netcat-0.7.1
  • Type ./configure –help | most to check if something needs to be tweaked in configure script
  • create a file named „description-pak“ with help of slackcreator and remove „pkgname: “ at start of all lines
  • Optionally create doinst.sh
  • Create a build script called <pkgname>.SlackBuild, customize the DOCFILES :!: & run it. A template:
#!/bin/bash
# file: netcat.SlackBuild
 
DOCFILES="ABOUT-NLS AUTHORS COPYING ChangeLog NEWS README TODO" # customize!
SLKCFLAGS="-O2 -march=i486 -mcpu=i686"
 
if [ ! -d doc-pak ]; then mkdir doc-pak || exit $? ; fi
cp $DOCFILES doc-pak || exit $?
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var || exit $?
CFLAGS="$SLKCFLAGS" make || exit $? # no colon!
#checkinstall

Notes: The content for CFLAGS came from Slackbuilds HOWTO & grep.SlackBuild. CFLAGS ist automatically respected by make. The options for ./configure came from Package Howto)

  • Correct Release field when checkinstall is asking! (add „bec“: eg 1 → 1bec ; see Perfect Package)
  • Correct Architecture field when checkinstall is asking! Default is i486, see also Perfect Package → Misc
  • Extract the package to a test dir & check if file owner is root:root in whole package. For Slack 10.2 and older the bin areas must be set manually to root:bin, see Perfect Package → Permissions and Ownerships
  • Save <pkgname>.SlackBuild and description-pak together with the package for later updates

FIXME for info pages: According to Package Upload info pages must be installed with install-info. I think checkinstall doesn't respect this. It seems that the current /usr/info/dir of the build host is taken, the new entry is added & the resulting file is just added to the Slackpackage (Seen during netcat test creation). Doesn't this destroy the /usr/info/dir of other user who installs that package? Shouldn't this go to doinst.sh?

Paketverwaltung

  pkgtool - SW: Installierte Pakete einsehen & interaktiv Pakete löschen & installieren
  installpkg -warn pkg.tgz
    Generate a report to the standard output about which files  and  directories would be removed or overwritten if you install the package, but do not actually install it.
    Necessary to be root.
    Achtung: nur ein '-' bei 'warn'!
  removepkg pkg
  installpkg pkg.tgz
  upgradepkg --verbose oldPkg.tgz%newPkg.tgz

Schriften

Moved to xorg

unsorted

xclip: read text into X selection (clipboard) from standard input

gnome-session - Start the window manager
php:
  -C : do not change the current directory to the directory of the executed script
  -q : start up in quiet mode, i.e suppress http headers
  -q & -C are only relavant for php-cgi-sapi, for the php-cli-sapi(?) this behaviour already is the default
  -v : see which sapi is on your System (cli or cgi (?))
bc -l - useful as command line calculator
  scale=10 : bc auf 10 Nachkommastellen einstellen
  sqrt(x)  : Wurzel aus x ziehen
  obase=16 : alle Ergenisse hexadezimal ausgeben
  ibase=2  : alle Eingaben werden als Binärzahl interpretiert
file datei - Bestimme den Typ der Datei datei
tree - list contents of directories in a tree-like format
  -p Print the protections for each file (as per ls -l)
  -u Print the username
  -g Print the group name
alias -p - prints the  list  of  aliases
alias name=value
exec prog
  ruft das Programm prog auf & beendet das laufende Script nachdem prog fertig ist. Alle Befehle nach exec werden nicht mehr ausgeführt.
sleep 3 - Halte (warte, mach pause) (Skript) für 3s an
usleep 300000 - Halte (warte, mach pause) (Skript) für 0.3s an
tty - zeigt das Terminal, das gerade verwendet wird (?)
fsck - check and repair a Linux file system
tee - read from stdin and write to stdout AND to file(s)
ginstall, install
  In Slack install is a Symslink to ginstall
  ginstall is newer -> use man ginstall for info!
locale - Hole Lokale-spezifische Informationen
locale -a - Drucke alle in /etc/profile.d/locale.sh einstellbaren locales, wichtig für /etc/profile.d/lang.sh
whoami - Wer bin ich
wvHtml infile.doc outfile.html
  convert msword documents to HTML4.0
xlHtml [-te] file.xls > out.html
  Excel-Datei in Html umwandeln;
  -te zum unterdrücken von leeren Zeilen/Spalten
ghex2 - Hexeditor
xxd (, hexdump) - make a hexdump (or do the reverse)
md5sum -c paket.md5
  In der Checksummen-datei paket.md5 muß eine Checksumme & ein Filename angegeben sein
  Prüft ob die angegebene Checksumme mit der berechneten Checksumme des Files Filename übereinstimmt
startx -- :1
  zweiten XServer auf F8 starten
kdmctl reserve
  Alternativ if kdm is the display manager. Found here: http://ubuntuforums.org/showthread.php?t=888139
dialog, xmessage, zenity (gdialog), kdialog
  display dialog boxes from shell scripts http://developer.kde.org/documentation/tutorials/kdialog/t1.html
dmesg - Bootmessages ausgeben
rename .JPG .jpg *.JPG
  alle Dateien, die auf .JPG enden in .jpg umbenennen
  tr macht sowas ähnliches auf String-Ebene (aus MP3 CD Burning mini-HOWTO)
sux, kdesu
  grafisches Prog als root starten (von Suse Konfigbuch)
su -c programm
  dito, zufällig bei alt.os.linux.slackware gefunden
befehl 2>datei.txt
  stderr nach 'datei.txt' umleiten
befehl &>datei.txt
  stdout & stderr nach 'datei.txt' umleiten
befehl >>datei.txt
  hängt stdout vom Befehl 'befehl' an die Datei 'datei.txt' an
lynx -stdin
  html-Seite von stdin anzeigen
lynx -dump [-nolist] url
  schreibt die Textform der Html-Seite nach Stdout; -nolist um die Links der Seite nicht mit auszugeben
xftree4 -> xffm - Dateimanager des Windowmanagers xfce
xfm - file manager, nix gscheids!
gv, ggv, kghostview  - PostScript & PDF Betrachter
xpdf - PDF Betrachter
ps2ascii, pdftotext - pdf (ps) -> text
pdfimages - PDF image extractor, geil!
ls -al | egrep ^d
  nur Verzeichnisse anzeigen
ls -C
  mehrere Spalten anzeigen (für Pipe nach less)
ls -1
  nur ein(e) Datei/Verzeichnis pro Zeile anzeigen
l -t (= ls -alFt)
  Dateien nach zeit sortiert anzeigen
l -d w*
  Alle Dateien & Verzeichnisse anzeigen, die mit 'w' beginnen, jedoch nicht in Unterverzeichnisse abtauchen
dircolors
  Aufgerufen von /etc/profile
  Schreibt die Farben für ls nach stdout
  Schreibt die Aliase d & v nach stdout, bisher keine Möglichkeit gefunden, daß zu konfigurieren
  /etc/DIR_COLORS ist bisher die einzige Möglichkeit das Verhalten von d & v zu ändern (2005-03-31)
  Eine Analyse von dircolors.c hat ergeben, daß die Aliase d  (=dir) & v (=vdir) fest in dircolors reinprogrammiert sind
wc -l datei
  -l Zeilen (-c Bytes, -m Chars, -w Words) einer Datei zählen, oder ohne Dateiangabe von stdin zählen
eject [-t]
öffnet [& schließt] das (u.a.) das CdRom Laufwerk
updatedb - Suchdatenbank aktualisieren
locate -i - schnelles, Suchen in der Suchdatenbank (-i ignore case)
find -mmin -10
  Alle Dateien ab dem akt. Verzeichnis finden, deren Inhalt sich in den letzten 10' geändert hat (schön zur Kontrolle von "make install" - vorsicht, funzt nicht immer)
find -name '*.cpp' | xargs grep -n Alfons | less
  Zeigt recursiv alle Zeilen in cpp-Dateien in denen 'Alfons' vorkommt
find -name '*.cpp' | xargs grep -l Alfons | xargs jedit
  recursiv alle cpp-Dateien, die 'Alfons' enthaltenn mit Jedit öffnen
find -(i)name '*datei*'
  Listet recursiv alle Dateien mit Namen 'datei' ab dem aktuellen Verzeichnis; i für ignore case
grep -ni 'suchwort' *
  Alle Dateien im akt Verzeichnis nach 'suchwort' durchsuchen; -n zeigt Zeilennumern; -i für ignore case
grep -B 30 'suchwort'
  30 Zeilen vor dem Treffer auch mit anzeigen, Input hier über stdin
grep -E 'pattern'
egrep 'pattern'
  Suche mit 'richtigen' (extented) Regular Expressions
egrep -v '^[[:space:]]*$' textfile - Leerzeilen aus Textfile entfernen
env
export -p
  zeigt gültige Umgebungsvariablen
getopt
  dient zum Parsen von Argumenten in Scripten, siehe auch /usr/share/misc/getopt
info readline
  zeigt Shell Shortcuts
import - screenshot in eine Datei sichern
mdir a:
  zeigt den Inhalt der Diskette im Laufwerk a an, ohne vorher mounten zu müssen
  mtools siehe file:///usr/share/doc/suse/qconfig_de/html/node229.html
[<ctrl>]<alt>Fx
  führt auf ein anderes Konsolenfenster.
  Auf F7 liegt das grafische X-System
  Auf F10 liegt der console log (= /var/log/warn ?)
<ctrl><alt><Backspace>
  beendet X-Server
<ctrl><alt><+>
  schaltet die Bildschirmauflösung um
pstree
  Ausgabe Prozesse in Baumform
ps aux
  Ausgabe Prozesse
  a alle Prozesse mit Terminal, auch von anderen Benutzern
  x Prozesse ohne ttys
  u display user-oriented format (verändert nicht die Anzahl der Ausgabezeilen)
fg bg - ???
jobs - alle Prozesse der aktuellen shell anzeigen
kill %x - x-ten Hintergrundprozeß der shell killen
killall -i java
  beendet alle Prozesse, die mit java ... gestartet wurden
  -i für Nachfrage vorher
kill -s SIGKILL 4197
  wenn der Befehl unten nicht wirkt...
kill PID
  Prozess mit der Prozess-Id PID beenden (Bei Jedit reicht anscheinend der Prozess mit der niedrigsten aller PIDs um alle Jedit-Prozesse zu beenden
top
  zeigt alle Prozesse (interaktiv)
type -p programm
  Bei Suse ist which ein Alias für type -p & damit das echte which verdeckt
which programm
whereis programm
  zeigt den (bin)-Ort eines Programmes
chsh
  Shell für einen Benutzer ändern
gpm
  Programm zur Verwendung von drag&drop in virtuellen Konsolen (kein Kommando), wird jedoch nicht unter X gebraucht! (siehe Suse7.3 Referenzhandbuch)
help:/
  Auflistung aller Kde-Programme
groups
  zeigt die Gruppenzugehörigkeit des Benutzers an
du -hs *
  Speicherplatzbedarf für das aktuelle Verzeichnis nicht recursiv
du -h
  Speicherplatzbedarf für das aktuelle Verzeichnis recursiv
df -h [Datei]
  Anzeige Auslastung Filesystem
kdf
  KDiskFree
free - Display amount of free and used memory in the system
chown -Rv root:root verzeichnis
  setzt setzt verzeichnis mit allen Dateien und Unterverzeichnissen auf Besitz root root
newgrp - log in to a new group (from intro-linux)
id - Display current user and group ID names
umask
  print actual user file-creation mask
umask 0037
  after this command
  creating a dir  results in drwxr----- (777 ^ !037= 740)
  creating a file results in -rw-r----- (666 ^ !037= 640)
  (executable flag for files is suppressed automatically although allowed with umask)
  Wir wahrscheinlich in /etc/profile gesetzt (intro-linux)
ln -s /media/flash flash
  Erzeugt einen symbolischen Link auf das Verzeichnis /media/flash  mit dem Namen 'flash'
cp -p
  Preserve owner, group, permissions, time
cp -r Quellverzeichnis Zielverzeichnis
  kopiert alles mit Unterverzeichnissen
  1. tail -f /var/log/messages

zeigt permanent Systemmeldungen, geil!!!

  1. rcinetd

zeigt Status vom inetd

  1. rcapache start/status/stop

startet Apache/ liefert Stausbericht/ stopt

  1. rcmysql start, # rcmysql status

startet mySql/ liefert Stausbericht/ stopt

cal -y

Important Files & Directories

todo

  • write user [Strg]+[D]
  • talk user
Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
becki/linux/commands.txt · Zuletzt geändert: 2020-10-09 07:37 von becki

Impressum - Datenschutzerklärung