forceway

  • Increase font size
  • Default font size
  • Decrease font size

Linux Cheat Sheet

E-mail Print PDF

Various notes, commands, and ways of doing things in GNU Linux. Some are taken from man pages, newsgroups, and the web. But mostly they were gained from hours of frustration. :) Contact me if you have suggestions.

shebang line, at start of script tells system what to interpret with: #!/bin/sh

ndiswrapper1.7 instructions:
nuke any existing kernal ndiswrapper,ko drivers
make clean
make install
ndiswrapper -i wmp54gs.inf
modprobe ndiswrapper
..then setup wlan0.. iwup, iwconfig, ifstatus...

use ; to seperate commands. use && to seperate commands and only execute the following command if first was successful.

equivalent of windows "start.exe": in kde check out "kfmclient exec"

kernel version: uname -r

dmesg for last boot msgs
/var/log/messages for kernel log

dhcpcd wont assign DNS servers if eth0 enabled but disconnected

if user is member of cdrom group, desktop automounter dont work

xdpyinfo for xorg version

samba server wont work unless encrypted passwords = yes and use / in paths, not \

set a users smb passwd with smbpasswd

add to current users search PATH: PATH=$PATH:/mydir  ...put that in .profile

setfacl for windows like file permission

streamripper http://hostdime.streams.bassdrive.com:8000 -r 10069 -o larger -u WinAmp3.2

lspci for pci bus probe
lsusb for usb bus!

serial port /dev/ttyS0
parallel port /dev/parport0

avrdude -p m8 -c ponyser -P /dev/ttyS0

gnomesu - sudo for gnome environment
'su -' necessary for suing nautilus

dvd+rw-mediainfo /dev/dvd will get dvd manufacturer/model

crypto:
To mount:
/etc/init.d/boot.crypto start
To unmount:
/etc/init.d/boot.crypto stop

ethtool eth0 to get ethernet link status

get superkey working, add to xorg.conf in InputDevice section:
Option "XkbOptions" "altwin:super_win" ***didnt work!!***

setup nvidia:
sax2 -r -m 0=nvidia

xvidtune can tell you refresh rate

search the man pages: apropos

beryl option to get games to run better: unredirect fullscreen windows

flash nokia n800:
./flasher-3.0.amd64 -F RX-34_2007SE_4.2007.26-8_PR_COMBINED_MR0_ARM.bin -f -R

Privoxy's config file on opensuse is stored at /var/lib/privoxy/etc/config
rcprivoxy start   to start privoxy

*********************** vga= info***************
After you've done this then pass the kernel boot line append line option, "VGA=791" for a 1024x768 @ 24 resolution. If you use lilo add that to the "append" line.

An example, ` append="vga=791" `. If you use grub append it to the kernel line.
An example of the append line for grub follows:
title           Debian (2.4.20 Framebuffer + RUwireless)
kernel  (hd0,0)/bzImage-2.4.20fbruwireless root=/dev/hda7 hdc=ide-scsi vga=791 console=tty1
Here is an explanation of the values you can use:
vga=xxx sets the framebuffer console to a specific resolution.
Here is a table you can use so it can help you decide
what resolution you want to use:
colour          depth   | 640x480  800x600  1024x768 1280x1024
256             (8bit)  |  769      771       773      775
32000           (15bit) |  784      787       790      793
65000           (16bit) |  785      788       791      794
16.7 Mill.      (24bit) |  786      789       792      795
*************************************************

Yast > System > etc/sysconfig Editor > System > Kernel > MODULES_LOADED_ON_BOOT

**************************************************
You did not state which version of Linux you were running. However, you may want to look at the following:

cat /proc/sys/net/ipv4/tcp_timestamps
cat /proc/sys/net/ipv4/tcp_window_scaling
cat /proc/sys/net/ipv4/tcp_sack

You will probably see the number one "1" returned for each of them. If so, all is good. If any of the values returned is zero you can change them with the following command(s):
**********************************************

how do I mount a /dev (ice) with specific permissions? add a rule to udev /etc/udev/rules.d/

get local ssh fingerprints and cat to a txt file?:
ssh-keygen -l -f /etc/ssh/ssh_host_key.pub > ssh_fingerprint.txt
ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub >> ssh_fingerprint.txt
ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub >> ssh_fingerprint.txt

recursively shred and remove current dirtree:
find -type f -execdir shred -u -v -n 3 -z '{}' \;
rm -rf *

QEMU: Ctrl-Alt-2 or -1 to switch to console
in console: info kqemu   to see if kqemu accelerator loaded

get ide drive info: cat /proc/ide/hdc/model, etc...

GUI sftp? in Konqueror use fish://ip

supposed to restart kicker:
dcop kicker kicker restart

enable delete instead of send to trash, in GNOME: gconf /apps/...nautilus/enable_delete

cat /proc/interrupts to get an irq list

project cryptmount can do dm-crypt stuff without superuser privileges

How to release/renew your IP address?:
ifdown eth0
ifup eth0
or
dhclient -r eth0
dhclient eth0
or
rcnetwork restart


current terminal size: resize

compress qemu qcow image: first zero it out with a disk wipe utility, then do
qemu-img convert -c -f qcow <img-name> -O qcow <new-img-name>

list active tcp & udp connections & process: netstat -tu --program
listening sockets: netstat -l --program
also check out: iptraf

count lines in files: wc -l *.cpp

determine dm-crypt encryption type: cryptsetup status /dev/mapper/_dev_loop0

tightvnc vncviewer popup: f8

find all hidden files in current directory:
find -name ".*"

bash reverse history search: ctrl-r

get openssl x509 fingerprint: openssl x509 -fingerprint -md5 -noout -in somecert.pem

Most distributions have core dumps disabled by default, thus you'll have to reenable them first. "ulimit -c unlimited" will do that for the current shell and all processes started from it.

find in files example: find . -name "*.cpp" -exec grep -q "meow" '{}' \; -print                         

get eth0 link speed: ethtool eth0

resuming jobs, job related commands:
http://linuxreviews.org/beginner/jobs/

how the **** do i exit vi??
To exit vi press ESC to make sure you are in command mode
1. Type ZZ or :wq to write (save the file) and quit
2. Type :q or :q! to quit without saving the file

determine what a file is: file

smart unzipper unarc untar thing: deco

good way to copy all files from one partition to another, if cloning for example: cp -axv /mount/sda1/* /mount/sdb1

move an opensuse 10.3 root partition:
copy all files to new partition.
opensuse uses disk by id. so you need to replace the ids with the new id or device name, in /etc/fstab and /boot/grub/menu.lst.
use supergrubdisk to install grub & make bootable.

current cpu frequency?: cat /proc/cpuinfo

acpi cpufreq parameters and limits?: cat /sys/devices/system/cpu/cpu0/cpufreq/...

usb device power requested, do this and look for bMaxPower: lsusb -v

list all files open for write: lsof | egrep " [0-9]*[wu] *REG"

search a man page: /

DNS information is most often found in a text file called resolv.conf. This file can be read using the cat command. A common place for this DNS file is:
/etc/resolv.conf although the name and location of this file may vary by Linux distribution.

find out XWindows mouse button names: xev

KDE show desktop command: dcop kicker kicker toggleShowDesktop

bind mouse buttons to commands: xbindkeys

get SUSE team package signing key on a suse system:
rpm -qi gpg-pubkey-9c800aca

restart plasma: kquitapp plasma && plasma 

pause process: kill -STOP pid

resume.. : kill -CONT pid

reencode mp3s: find . *.mp3 -maxdepth 0 -exec lame --preset 128 {} 128k/{} \; -exec id3cp {} 128k/{} \;

rpm unpack: rpm2cpio foo.rpm | cpio -idmv --no-absolute-filenames

set time from internet: ntpdate pool.ntp.org

opensuse version: cat /etc/SuSE-release

mount a smb/windows share:
mount -t cifs //server/share /mnt --verbose -o user=username

to use the library being placed in a ``non-standard'' place. You can also use environment variables to control things. In particular, you can set LD_LIBRARY_PATH, which is a colon-separated list of directories in which to search for shared libraries before the usual places. If you're using bash, you could invoke my_program this way to search for libraries in the local directory, using:
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH  my_program

delete a list of files in a text file called file.txt, one per line:
xargs rm < file.txt

bump up kwin's refresh rate (see this link):
kwriteconfig --file kwinrc --group Compositing --key RefreshRate <value>

get battery info:
cat /proc/acpi/battery/BAT0/info
cat /proc/acpi/battery/BAT0/state
acpi -V

truncate / crop the end off of a file:
truncate -s SIZE filename.dat

truncate head / beginning of a file:
tail -c SIZE > newfile.dat

throttle zypper (requires fairly new version):
edit /etc/zypp/zypp.conf , you will see download min and max parameters

xorg set gamma:
xgamma

umask? umask is subtracted from all bits to get permission for newly created files and dirs..
777 - umask 022 = 755 = u+rwx g+rx o+rx (this is for directories. files cannot be given execute bit on creation, so file permissions would be 644 = u+rw g+r o+r)

use egrep for grep boolean OR:
egrep "match1|match2|match3"

If festival returns the following error message:
Linux: can't open /dev/dsp
Switch to ALSA output by adding these lines to the end of your .festivalrc file, or to /usr/share/festival/festival.scm (source):(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Command "aplay -q -c 1 -t raw -f s16 -r $SR $FILE")

vnc server doesn't work in openSUSE 11.2? try removing IP6 localhost:
http://old.nabble.com/Problem-with-OpenSuSE-11.2-and-KDE4-td26505322.html

Desktop Effects (simple ccsm) briefly enables then immediately disables... i.e. flashes on then off? But it works ok for other users or root? Some config file in your home folder is causing it. We don't know exactly which file it is so you'l have to wipe out all . dot files and folders in your home dir. You can move them somewhere else temporarily instead of just deleting them.

nvidia-settings overclocking / Coolbits setting won't stay after rebooting or logging out? In openSUSE create a script /etc/X11/xinit/xinitrc.d/overclock_nv.sh . In the script put (for example):
#!/bin/bash
#overclock nvidia 8600 gts
nvidia-settings --assign="GPUOverclockingState=1" --assign="GPU3DClockFreqs=746,1157"

No sound on ASUS M4A77D / VT1818S ? Get a newer kernel or the latest alsa-driver build.

build / make in parallel, using mulitple cores: make -j N

KDE ATI desktop effects, composting disabled after reboot? In Desktop Effects -> Advanced tab, check 'Disable functionality checks'.

If you want to force fsck on the next boot, create a file called /forcefsck . If this file is present during the next boot - the fsck is forced.
# touch /forcefsck

How do you send ctrl-alt-f1 to a virtualbox guest? "host key"-F1 , where "host key" usually is the right CTRL

openSUSE 11.2 KDE eclipse UI problems / draw bug / greyed out ? Create a script start_eclipse in the eclipse folder. Put this inside it and use it to run eclipse:
export GDK_NATIVE_WINDOWS=true
./eclipse

PLAY your NEWEST music... A script to create a music playlist sorted by file modification time, and then open it using VLC. Mp3, m4a, and ogg files are included.:
#!/bin/bash
cd /home/someuser/Music && \
find . -iname "*.mp3" -print0 -or -iname "*.m4a" -print0 -or -iname "*.ogg" -print0  | xargs -r0 stat -c %Y\ %n | sort -rn | grep "\..*$" -o > newest.m3u && \
vlc newest.m3u

Stop a command after a certain amount of time... run the command in one terminal (or background), then use sleep followed by killall. for example, to download a file, stopping after 6 hours:
terminal1: wget -c http://some.com/filedownload.zip
terminal2: sleep 6h ; killall wget

Format an SD card. A command line/console/terminal approach:
1. fdisk -l (to see what devices present)
2. Unmount the relevant device first (eg /dev/sdb1) if mounted with something like:
unmount /dev/sdb1
3. For FAT32:
mkdosfs -F 32 -n <VOLUME_LABEL> /dev/sdb1

Copy a damaged file, example using dd fills dmg areas with zero:
dd if=/media/Kingston/DCIM/100MEDIA/MEDI0016.AVI of=MEDI0016.AVI conv=noerror,sync
Or try ddrescue.

 

Last Updated on Tuesday, 31 August 2010 01:28