String replace
sed -i 's|STRING_FROM|STRING_TO|g' FILE
add line to a file
sed -i '13i\YOUR_TEXT' FILE
Extract RPM Archiv
rpm2cpio FILENAME | cpio -i --make-directories
Get file atime, mtime, ctime
stat FILE
Change mtime from a file
touch -d "2005-05-05 15:55:55" FILE
Create selfextract archive under Linux
makeself.sh [-bzip2] DIR archiv.run "DESCRIPTION" COMMAND
Create Linux software RAID
mdadm --create /dev/md2 --level=raid5 --raid-devices=4 --spare-devices=0 /dev/sdb4
/dev/sdc4 /dev/sdd4
Wake On Lan (WOL)
wakeonlan 00:11:22:33:44:55
Change root and start bash
chroot /mnt /bin/bash
Enable / Disable swap
swapoff -a
swapon -a
extract initrd.gz
gunzip < ../initrd.gz | cpio -i --make-directories
#gzip -dc /tftpboot/u804i386live/casper/initrd | cpio -id
extract initrd.lz
unlzma -c -S .lz ../initrd.lz | cpio -id
compress initrd
find ./ | cpio -H newc -o > ../initrd
gzip ../initrd
Extract *.deb
dpkg-deb -x file.deb /tmp
Add script to a runlevel
sudo update-rc.d providername start 90 2 3 5 . stop 10 0 1 4 6 .
Most used commands
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
VNC on slow connection
xtightvncviewer -compresslevel 9 -quality 0 192.168.0.100
xvnc4viewer -ZlibLevel 9 -LowColourLevel 0 192.168.0.110
Format partition as FAT16
mkdosfs -F 16 -n SDCARD /dev/sdd1
Forcing kernel to use new partition table after fdisk
partprobe
list blocking prozesses
lsof /mnt
Add a existing user to existing group
usermod -a -G GROUPNAME USERNAME
Delete user from group
edit /etc/group and remove user name
or
id -nG USERNAME
usermod -G group1, group2, group3,... USERNAME
# test gpasswd
Mount SSH
sshfs user@192.168.1.2:/media/images /mnt
unmask
global: /etc/profile
echo "umask 0000" >> ~/.profile
check for listening ports
netstat -anp | grep 1234
lsof -i | grep 1234
dpkg install force-architecture
dpkg --force-architecture -i *.deb
display bandwidth usage
iftop
log loadavg
echo "$(date) $(cat /proc/loadavg)" >> loadavg.log
convert qcow2 to raw image
qemu-img convert -f qcow2 root.qcow2 -O raw root.raw
losetup
losetup -a - list all used devices
losetup -d loop_device - delete loop
losetup -f - print name of first unused loop device
reconfigure keyboard / console
dpkg-reconfigure console-setup
kill all prozess from a user
ps -u USERNAME | awk '{print $1}' | xargs kill -9
connect with gnome nautilus to ssh
sftp://root@SERVER/SHARE
disable monitor power save (disable DPMS)
xset -dpms
disable console, x11 screensaver
xset s 0 0
xset s noblank
xset s off
xset -dpms
setterm -blank 0
setterm -powersave off
setterm -powerdown 0
force umount
sudo umount -l -f /mnt/mountpoint
convert nero cd image to iso
nrg2iso infile.nrg outfile.iso
enable harddisk udma mode
hdparm -d1 /dev/hda
remove multiple spaces from a string
cat x.txt | tr -s " "
create uniqe file from two files
dos2unix adr_*.txt; cat adr_hp.txt adr_sel.txt | sort | uniq > adr_uniq.txt
copy files between hosts with SSH and tar
tar -cf - /some/file | ssh host.name tar -xf - -C /destination
read cd volume label
dd if=/dev/hdd bs=1 skip=32808 count=32 2> /dev/null | tr -d " "
rebuild initrd
gzip -d miniroot.gz; mount miniroot /mnt/ -o loop; vi /mnt/linuxrc; gzip --best miniroot
Fix slow SSH login
echo "UseDNS no" >> /etc/ssh/sshd_config
set hostname
echo myhost.local > /etc/hostname; /etc/init.d/hostname.sh start
start xterm in Xorg session
cat < $HOME/.xsession
xterm
EOF
change language temporary on command line
export LANG="en_US.UTF-8"
fix broken package with apt-get (dpkg)
rm /var/lib/dpkg/info/PACKAGE_NAME*
dpkg –remove –force-depends –force-remove-reinstreq PACKAGE_NAME
configure timezone
dpkg-reconfigure tzdata
allow user to administrate system (add to adm group)
usermod -a -G adm $USER
change password non interactive
echo "root:terceS" | chpasswd
clean mbr
dd if=/dev/zero of=/dev/sdb bs=446 count=1
create checksum
echo "foo" | md5sum
MD5-Hash password
echo terceS | mkpasswd -s -H MD5
create tmpfs
cat < $TARGET/etc/fstab
tmpfs /tmp tmpfs defaults 0 0
EOF
set / change volume label
e2label /dev/sda1 newlabel
tune2fs -L newlabel /dev/sda1
clean ubuntu trash
sudo rm -rf ~/.local/share/Trash/files/*
convert ISO-8859-1 to UTF-8
iconv --from-code=ISO-8859-1 --to-code=UTF-8 file.in > file.out file.in > file.out
remove multiple blanks
cat in.txt | sed "s/[ ][ ]*/ /g" > out.txt
Extract Windows cab file
cabextract CAB_FILE_NAME.exe
set recursive directory rights
find . -type f -exec chmod 644 {} \;
extract pages from PDF file
pdftk IN.pdf cat 1-5 output OUT.pdf
merge pdf sites to a single dokument
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -sOutputFile=out.pdf *.pdf
Ubuntu german locale
locale-gen de_DE.UTF-8
echo 'LANG="de_DE"' > /etc/default/locale
cat < ~/.bashrc
export LANG=de_DE.UTF-8
export LC_ALL=de_DE.UTF-8
EOF
convert charcode
iconv --from-code=UTF-8 --to-code=ISO-8859-1 IN.txt > OUT.txt
find duplicate files
fdupes -r . > fdupes.txt
disable Nvidia logo on Xorg start (/etc/X11/xorg.conf)
Section "Device"
Option "NoLogo" "True"
EndSection
Reload gnome panels
killall gnome-panel
#? killall gnome-panel nautilus
SSH X11 forward
ssh -Y YOUR_SERVER -l YOUR_USER xclock
Mirror a homepage with wget (http://wiki.ubuntuusers.de/wget)
wget -m http://www.YOUR_DOMAIN.com --reject=pdf,jpg,gif,png,flv,m4v
format DVD-RW
dvd+rw-format -force /dev/cdrom
update kernel partition table
apt-get install -y parted && partprobe
sync files from webserver
wget -m -np -nH --cut-dirs=1 http://www.YOUR_DOMAIN.com/stsbox/ --reject="index*"#
grep list only the file name
grep PATTERN -o *
view disk UUID and label
blkid /dev/sda1
Do you like this page? Then support it. Please click the AD below and visit the sponsor. Thank you!