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' works
but 'ping' 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 (like I do) 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, 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

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

In Gnome my number pad stops working occasionally. I think it may be a
shortcut I'm accidentally enabling, but somehow the accessibility keys are
activated. To resolve the problem, go to the control panel, accessibility,
and enable and then disable the keyboard accessibility features.

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, run 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
vmstat -d

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)

calendar - List important events from today and tomorrow

Utility to print source code - trueprint

Show only headers of GET request: curl -IXGET

Display only uncommented, non-blank lines in a config file: grep -v '^#\|^$' <config_file>

Updated Apr 24, 2020