linux tips

sox - Modify wav files (speed, echo, fade, etc)

zcat /proc/config.gz | less to get the configuration of the running kernel.

To turn off beeps
-----------------
xset b off
xset b 0 0 0

In terminal: echo -e "\33[11;0]"

KDE: Control Center (kcontrol), Sound & Multimedia, System Notifications,
Quick Controls -> Turn Off All Sounds (check 'Apply to all applications'),
Control Center (kcontrol), Sound & Multimedia, System Bell, Volume 0%
(check 'Use system bell instead of system notification)

Burning CDs - k3b has a nice GUI frontend

Printing text files, one page per sheet with title:
a2ps -R --columns=1 --center-title='the title' <filename>

sux to 'su' to root and maintain the X display exported to your local machine.

On the workspace switcher applet, put your mouse over the applet and use the scroll button to switch desktops.

On SuSE 9.3, you can have unreliable DNS issues where 'host example.com' works
but 'ping example.com' doesn't work. To fix this, turn off the Nameserver
caching daemon: chkconfig --del nscd, rcnscd stop

On SuSE 9.3, if you dislike the default mouse icons, edit
/etc/sysconfig/windowmanager and change the X_MOUSE_CURSOR value. Possible
themes can be found in /usr/X11R6/lib/X11/icons/

If you get the following error running BitTorrent apps: ImportError: No module
named BitTorrent.download, just set the path to python:
export PYTHONPATH=/usr/lib/python2.3/site-packages

In Mutt, to bounce all messages to another address, type T, then a regex
(to select all, use .*), then ';b' (; means to apply the bounce to the tagged
messages).

In Mutt, to mark all messages as read, type '.c' (without the quotes of course).

Rename multiple files at once, use the rename command, contained in
util-linux (on Fedora at least).
For example, to rename all .htm files to .html, run:
rename .htm .html *.htm (change .htm to .html on all files matching *.htm)

Log a shell session to a file, run 'script', then run all your commands.
If you pass it a filename, it will log to that file, otherwise it will log
to a file called typescript.

Reformat a program written in C with utility called indent.

Find out what version you're running: cat /etc/issue or if the command
exists, lsb_release -a

When a command isn't working right and you're out of ideas, try running
strace and then the command to see everything it's trying to do. The output
is extremely verbose, but it can help you troubleshoot the issue.

Figure out what process is running on a specific TCP port (1000):

lsof -i TCP:1000
fuser -n tcp -v 1000
netstat -nlp | grep 1000
ss -atpu

Monitor disk activity
file access routines: sar -a
activity for block devices: sar -d
paging activity: sar -g
iostat
vmstat -d
iotop

List Samba shares:
smbclient -L //<host> (hit enter at password prompt)

Mount Samba share with domain
mount -o "username=<user>/<DOMAIN>" //server/share /mnt
On newer versions of Linux that use CIFS instead of SMBFS
mount -o username=<DOMAIN>/<user> //host/share /mnt

dpkg -l = list packages
dpkg -L <package name> = files contained in the package
dpkg --get-selections = installed packages (or those marked deinstall)
dpkg -P <package name> = purge package (remove configuration files)
dpkg -S <path to file> = the package that owns the file
dpkg --fsys-tarfile <package.deb> | tar xf - = extract all the files in a debian package

aptitude (survival guide)
'+' - mark all packages in selected group for upgrade
'g' - preview action, 'g' again to perform upgrade
'[' or ']' - expand/collapse group to packages
Sequence for security updates: u, +, g, g, q

cleanlinks - Removes empty directories and dangling symlinks from pwd down

Find files with a certain permission (writable by owner in the example)
find . -type f -perm -u=w

Sort files and folders by size: du -sm * | sort -n

List the size of all directories even if they have spaces in the name: find . -type d -maxdepth 1 -exec du -sh {} \;

Generate a random 12-character password: openssl rand -base64 12
pwgen 16 (easier to remember)
pwgen -s 16 (more secure, less memorable)

Manual non-X session using ssh-agent (add to .bashrc):

alias sk='eval `ssh-agent` > /dev/null; ssh-add <ssh_key_path>
Also: kill $SSH_AGENT_PID (add to .bash_logout)

Utility to print source code - trueprint

Show only headers of GET request: curl -IXGET http://example.com

Display only uncommented, non-blank lines in a config file:

grep -v '^#\|^$' <filename> or grep -vE '^\s*($|#)' <filename>

Time how long it takes to calculate pi to 5,000 decimal places: time echo "scale=5000; a(1)*4" | bc -l

mtr - Alternative to traceroute that combines features of ping

To show output after 10 rounds then exit: mtr -c 10 -r google.com
To show long hostnames: mtr --report-wide -c 10 -r google.com

Show hardware / system info

lspci - List all PCI devices
lsusb - List all USB devices
lsblk - List all block devices
lscpu - Show information about the CPU architecture
dmideode - Show DMI / SMBIOS info
neofetch - Print general system overview with an ascii art OS logo