Commands and Shortcuts

A collection of miscelaneous commands and shortcuts

 

Shortcuts

Alt+F2 run a command
Strg+Alt+F1 change to login shell nongrafical interface, bash
Strg+Alt+F7 change back to GUI
Strg+Alt+Esc: in XFCE: get a skull-mousepointer to kill X-Server/GUI-application

Hardware–System–Information

see Hardware–System–Information

Execute Commands as another User

Execute command as superuser root
sudo «command»
simulate initial login as another user
sudo -u «username» -i

Update

Update package-informations & all software, reboot
sudo aptitude update && sudo aptitude full-upgrade
sudo reboot

Informations about Packages

General Information
aptitute show «packagename»
Verify if a package is installed – long display – result for installed package: ii (Desired|Status|Err?)
dpkg -l | grep «packagename»

Partitions / Filesystems

Partitions should be unmounted for repair purposes!

check a Linux ext2/ext3/ext4 file system even if it seems clean, be verbose and assume an answer of `yes’ to all questions
sudo e2fsck -f -v -y /dev/sdb1

Archives

Create archive
tar -cf «targetfile».tar -C «folder which contains the folders/files to kompress» «names of folders/files to include»
Extract archive
tar -xf «sourcefile».tar -C «targetfolder»
Create archive being verbose and using bz2
tar -cvjf «targetfile».tar.bz2 -C «folder which contains the folders/files to kompress» «names of folders/files to include»
Create archive being verbose, using bz2, using numbers for user/group names and not recursing into subdirectories
tar -cvj --no-recursion --numeric-owner -f «targetfile».tar.bz2 -C «folder which contains the folders/files to kompress» «names of folders/files to include»
Extract archive being verbose, preserving permissions, keeping existing files and using bz2
tar -xvpkjf «sourcefile».tar.bz2 -C «targetfolder»

Textprocessing

There are many different tools for text processing on Linux systems. Some examples:

sed

sed: replace text in a file (works line by line)
sed -e 's/«old text»/«new text»/g' -i «file»

perl

perl: replace text in a file (works line by line)
perl -pe 's/«old text»/«new text»/g;' -i «file»
perl: append new line after existing lines
perl -pe 's/^(.*«part of existing lines».*)$/\1\n«new line»/g;' -i testfile

awk

awk: get first field of line with «packagename» as second field
dpkg -l | awk '$2~/^«packagename»$/ {print $1}'

Miscellaneous

Add a directory (with scripts/binarys) to your PATH
export PATH=$PATH:«directory»