Ted's Slackware 12.2 command reference. Ted Felix (www.tedfelix.com) April 2009 Help man Online manual. Try "man mount" to get the manual page for the mount command. Also try "man 1 intro" to see the introduction for section 1 of the manual. See info. info Like man, an online manual. Just type info to find out what's available. Sometimes the "info" manual (if it exists) is better than the "man" manual so always try both. A good example is "info grep" which is far more detailed than "man grep". whatis Search for a one-line description of a command. Gives the title from the man page. See apropos. apropos Searches the whatis database on both command name and man page title. Use this if you aren't sure of the command name. Try "apropos MSDOS". See whatis. help (bash) Similar to man and info, but gives help on a bash built-in command. Try "help", "help cd", and "help for". man2html If you get sick of man, grab the man page from /usr/man, "gzip -d" it, then run man2html on it and view it in html. Good for really huge man files like gcc's. xman (X) A GUI version of man. A bit clunky, but it works. Good for browsing entire sections of the manual. slackbook (Slackware) A great intro to Slackware found on CD #1. Getting Started passwd Change your password. adduser (Slackware) Interactive add user script. Uses "useradd" to do its work. Takes into account unique user needs for Slackware. Found in /usr/sbin. Always create a new user and log in as them. *Never* work as root. See sudo. exit Logs you out. Ctrl-D works too. sudo Run a command as root. To power off the computer: "sudo /sbin/poweroff". For sudo to work, you must add yourself to "/etc/sudoers" (e.g. "userid ALL = ALL"). man sudoers for more. See sudoedit. sudoedit Edit a file as root. Uses the editor in your EDITOR environment variable. Allows editing of files owned by root when you aren't root. See sudo. poweroff Powers the computer off. Found in /sbin. Can only be run as root, so use sudo: "sudo /sbin/poweroff". See shutdown and sudo. reboot Reboots the computer. Found in /sbin. Can only be run as root, so use sudo: "sudo /sbin/reboot". See shutdown and sudo. shutdown Shutdown or reboot the computer. To turn the computer off: sudo /sbin/shutdown -h now To reboot: sudo /sbin/shutdown -r now xorgsetup (Slackware) Configures X for your video card and monitor. Run it once each time you change video hardware or when you first install Linux/X. It in turn invokes "Xorg -configure" to do most of its work. See startx and xorgconfig. startx Brings up X. Be sure to run xorgsetup first or else X will not take full advantage of your video card and monitor. whereis Searches a list of typical system directories (e.g. /bin, /sbin, /etc, ...) for a filename. "whereis libm" will find the math library. "whereis ls" will find the location of the ls command. This is useful when you are trying to run administrator commands as a regular user. Regular users do not usually have /sbin in their paths, so this: "sudo shutdown" will generally fail. "whereis shutdown" tells you that shutdown is in /sbin. So "sudo /sbin/shutdown" will work. See "which" and "slocate". chsh Change your login shell. (If you prefer csh, ksh, zsh, or something else.) Alt-Ctrl-F1, Alt-Ctrl-F2, Alt-Ctrl-F3... Switches between pseudo-terminals. Note that you can also switch with just Alt-F1, Alt-F2, etc... However, when in X, Alt and Ctrl are required. File Utilities (simple) mc Midnight Commander. Console file manager. pilot Pilot. Console file manager. ls list files in a directory. Some useful options: -l give details such as sizes and dates -a show all files including hidden ones -t sort by date/time -r sort in reverse order Try "ls -lrt". Also try "vdir". tree Like "ls", but shows the directory structure in a colored tree diagram. cd change to another directory pwd displays the current directory mkdir Make a directory. mv Move or rename files. rename Rename a batch of files based on a pattern. cp Copy files. rm Delete a file. rmdir Delete a directory that is empty. cat Copies a file to the display. less A file pager for displaying large files a page at a time. Better than "more" as you can page up and down. Try "cat /etc/passwd | less" or "ps aux | less". most Like less, but can split the view into multiple windows. Try "Ctrl-X 2". more A file pager. See "less". pg Another pager like less and more. which Finds a command's location in the path. See whereis and slocate. type (bash) tells you where a command will be run from. Similar to which, but indicates whether the command is hashed or built-in. Text Editors (Graphical, requiring X) mousepad (X) A text editor for X. kwrite (X/KDE) Includes code highlighting. Default KDE editor. kedit (X/KDE) Simplest KDE text editor. Fewer features than kwrite. kate (X/KDE) KDE's Advanced Text Editor. Like kwrite, but with many additional features like a filesystem browser and a shell window. xedit (X) A very strange editor for X. Text Editors (Console, easy to use) nano Uses Ctrl keys for functions. Function reminders always on bottom of screen. Very easy to use. pico Use this if nano isn't available. This is like nano but with fewer features. joe Remember WordStar? "Ctrl-K H" for help. mcedit Uses the F-keys for functions. jed While it has nice menus using the Alt key, the Delete, Home, and End keys do not work. If they can be fixed (maybe with a proper keymapping?) this would be a great editor. Text Editors (Console, hard to use unless you know them) emacs The "Edit MACroS" editor. jove A version of emacs. "teachjove" will load up a tutorial on jove. vi The "VIsual editor". In Slackware this links to elvis. elvis A version of "vi". vim A version of "vi". VI iMproved. Try "vimtutor" which will help you learn vi and vim. evim A slightly easier, modeless version of vim. ed A line editor like DOS's EDLIN. X Applications xlock Lock the local display until a password is entered. rclock Clock with reminders (in ~/.rclock). Also try xclock and oclock. spider Solitaire. xcalc Calculator. xneko Cat chases mouse. xterm Console window. xmag Screen magnifier. KDE Applications kcalc KDE calculator kmix KDE audio mixer. kaudiocreator KDE CD ripper. khexedit KDE GUI hex editor. See "bpe" for the console. kturtle KDE turtle programming language. Simpler than LOGO. Miscellaneous sc Console spreadsheet application. Press ? for help. mkpasswd makes random passwords factor Prime factors. shuf Generate random permutations. Shuffle. cal Perpetual calendar. gnuplot Mathematical plotting program. At the "gnuplot>" prompt, try "plot sin(x)". hunt A networked multi-player maze deathmatch game. Audio Utilities rexima Text console mixer. sox Audio manipulation utility. flac FLAC codec. Lossless audio compression. Patent-free. lame MP3 codec. Due to patent issues, this usually needs to be downloaded separately, built, and installed. oggenc Ogg Vorbis encoder. Ogg is similar to MP3 but without patent issues. normalize Normalizes audio files so that the loudest point is as loud as possible. User Management passwd Change your password. whoami Displays your user id. logname Displays your user id. su Become root. To be safe, use "sudo" or "sudoedit" instead. groups Display groups you currently belong to. id Display user id, group id, and groups. useradd Add a user. See Slackware's adduser script. gpasswd Manage groups. newgrp Log in to a new group. See "sg". sg Run a command as member of another group. groupadd Add a group. Also check out groupdel and groupmod. last Show a list of login events. Note that the list is in reverse chrono order, so the newest are at the top. "lastb" shows only the bad login attempts. users Show users currently logged in. Also try "rusers". who Show users currently logged in along with some statistics. Also try "rwho". w Show users currently logged in along with lots of statistics. ac Show user connect time. lastlog Displays the last login date/time for all users. File Utilities (advanced) chown Change owner and group of a file. chmod Change permimssions on a file. tail Displays the end of a file. Use the -f option to follow a file as it is being written to. Great for watching log files. See tailf. tailf Like "tail -f" but more efficient. head Displays the beginning of a file. wc Displays a line count, word count, and byte count for a file. grep Searches files for a string (e.g. "grep hello *.txt"). See rgrep. rgrep Searches a directory tree recursively for files containing a string. To search all .c files recursively for "#define": rgrep -R '*.c' '#define' . See cscope. replace (MySQL) Replaces strings with other strings in a file or files. Global find and replace. Use along with "find" if you need to recurse subdirectories. look Performs a binary search on a sorted file for a value at the beginning of each line. gpg OpenPGP encryption. cmp Binary file compare. diff Text file compare. diff3 Three-way file compare. sdiff Shows a side-by-side diff of two files. merge Automatic three-way merge. comm Compare sorted files. find Finds files in a directory hierarchy. To find all the .txt files starting in the current directory ("."): find . -name '*.txt' See slocate. find can also be used to recurse subdirectories and run a command: find . -name '*.c' -exec ls -l {} \; This gives any command the ability to recurse subdirectories. See rgrep. slocate Finds files in the filesystem using a database for fast searching. Have to do a "sudo slocate -u" to build the database at first. See find, updatedb, which, and whereis. ln Make hard or symbolic links between files. link Makes a hard link between files. lndir (X) Makes symbolic links to an entire directory worth of files. rev Reverse the lines in a file. See tac. tac Display the lines in a file in reverse. (Get it? "tac" is "cat" spelled backwards.) See rev. sort Sort the lines in a file. uniq Eliminate dupes in a file. File must be sorted for this to work. See sort. split Split a file into pieces. Useful for getting a large file on multiple floppy disks or CDs. tar Gathers files into an archive. Similar to the ubiquitous ".zip" files but not compatible. bzip2 Compresses a file to save space. Use with tar. unzip Work with ".zip" files. Use "zip" to make .zip files. tee Pipe standard input to standard output and to a file at the same time. touch Change a file's date/time. lsof List open files and statistics for each. File Hacking Commands file Attempts to identify a file's type (e.g. JPEG image, MP3 audio) by examining its contents. xxd Hex dump. Includes ASCII. This can also convert back from a hexdump to a binary file. It can create C code with the -i option and display EBCDIC with the -E option. hexdump Dumps a file in hex to the display. Try the -C option for hex and ASCII. od Octal dump. Can also dump in hex: od -Ax -x /etc/motd Can also include ASCII chars: od -Ax -x -c /etc/motd See hexdump. strings Shows things that resemble strings in a file. Use for hacking binaries. bpe Console hex editor. See khexedit for KDE. X Window System Utilities xwmconfig Switch window managers (e.g. KDE, Xfce, GNOME, ...) xorgconfig Configure X for your video card and monitor. Use this only of xorgsetup doesn't work. xdpyinfo Displays lots of X related info. Networking Utilities netconfig (Slackware) Slackware script to configure Internet access. ifconfig Configure Ethernet interfaces. nmap Port scanning tool to make sure your firewall is working. "nmap localhost" to scan the local machine. zenmap GUI for nmap. iptraf IP Traffic monitor. Packet sniffer. netwatch IP monitor. Packet sniffer. tcpdump Dump traffic on a network. Packet sniffer. dig DNS lookup. host DNS lookup. nslookup DNS lookup. ftp File transfer protocol. Transfers files between computers. Also try gftp (X GUI), lftp, ncftp, and sftp (secure ftp). wget Website capture utility. Some websites deny access to wget. Use the -U=AGENT option to get around this. ssh Secure shell. Connect to a shell prompt on another machine. Like telnet, but encrypted. screen Gives you virtual terminals over a single telnet connection. Does this work with ssh? gkrellm GNU Krell Monitors. System monitor. Monitors CPU, Processes, Disk usage, Memory, Network, etc... traceroute Show the routers along the way to a host. (traceroute6 supports IPv6) tracepath Similar to traceroute. (tracepath6 supports IPv6) iptables Firewall and NAT (Internet connection sharing) utility. netstat Displays various network information. socklist Displays a list of open sockets. Also try "ss -a". Device Utilities cfdisk Disk partition table manipulator. Also try fdisk and sfdisk. parted Partition manipulation program. Can create, delete, resize, and copy partitions. volname Returns the volume name (label) of a device. smartctl The SMART (IDE hard drive diagnostics) utility. "smartctl -a /dev/hda3" gives all the info on hda3. Use mount to figure out what device to check. df Shows how much space is free on your hard drives. du Shows how much disk space is used by a directory and its subdirectories. To see just a usage summary for each file and directory: du -sh .* * The "h" option gives human readable sizes and the .* gets hidden files. du -s * | sort -n for a nice sorted version. fsck Check a filesystem for errors and fix them. Like the old DOS CHKDSK. stat Gives lots of information about a file. mount Mount a device on the filesystem. Without parameters, mount shows the mounted devices. umount Unmount a device. cdparanoia Audio CD reading program. Try on a bad CD and it should indicate where the problems are. (Older version is called cd-paranoia.) dfutool Device Firmware Upgrade tool. dd Copy from one file or device to another. "dd if=/dev/fd0 of=floppy.img" copies an entire floppy to a file. diskcopy Floppy disk copy script. Uses "dd" to do the copy. fdformat Format a floppy disk. This is a low-level format. It will not put an MSDOS filesystem (or any other kind) on the floppy. gkrellm (X) GNU Krell Monitors. System monitor. Monitors CPU, Processes, Disk usage, Memory, Network, etc... iostat CPU and Device statistics inotifywait Waits for changes to a file then quits. inotifywatch Collects statistics on accesses to a file. lsdev Displays device information like port addresses and IRQs. lshal Displays HAL devices. Try "lshal | grep info.product". systool Displays system device info. mpstat Display CPU statistics. procinfo Displays system status info. sync Flush filesystem buffers (disk cache). lspci List all PCI devices. Process Utilities & (bash) Place this at the end of a command line to run the command in the background. E.g. when in KDE: "kwrite readme.txt &" Ctrl-Z bg (bash) If you forget the "&" at the end of your command line, you can press Ctrl-Z to suspend the process, then enter the "bg" command to continue the process in the background. ps Shows running processes. "ps aux" for all the processes. "ps ux" for just yours. pgrep Find a process by name. E.g. "pgrep -l syslogd" top Shows processes that are using the most CPU in real-time. pstree Shows processes in a tree structure. nice Runs a command at low priority to be nice to other users. Also try "renice". nohup Run a command immune to disconnects (hangup signals, SIGHUP). killall Kill a process or processes by command name. "killall syslogd" kills the system logging daemon. kill Kill a process or just send it a signal. "kill -l" to see a list of signals and their values. pkill Similar to killall but slightly more dangerous as it does a substring search rather than a whole word search. So "pkill acpid" will kill the process named "acpid" but it will also kill the process named "kacpid". To avoid this, use ^ and $ like this: pkill ^acpid$ See pgrep. System Utilities date Display or set the date and time. env Display or modify the environment. Try printenv too. free Displays memory usage. gkrellm (X) GNU Krell Monitors. System monitor. Monitors CPU, Processes, Disk usage, Memory, Network, etc... Requires X. tload Console system load graph. Numbers at top are load averages. See uptime for more. xload (X) Load histogram like tload, but for X. slabtop Some sort of memory monitor. Press "q" to quit. taskset Retrieve or set a process's CPU affinity (which CPU the process will run on). uptime Displays system uptime and other info. Also try "ruptime". uname Prints various system information. Try "uname -a" to see everything. vmstat Show virtual memory statistics. at Schedule a job for later execution. dmesg Displays the messages from the last boot. watch Runs a command every two seconds. Try "watch ps". sysctl Display and change kernel parameters. pkgtool (Slackware) Slackware's package management tool. Use this to view, install, and remove packages. Also check out the other Slackware package tools: installpkg, removepkg, upgradepkg, explodepkg, and makepkg. Kernel Utilities lsmod List the loaded kernel modules. modinfo Display information about a kernel module. Try "modinfo button". modprobe Insert and remove kernel modules with dependency checking. insmod, rmmod Insert and remove modules without dependency checking. Use modprobe instead of these in most cases. Shell Programming echo Display something on the screen. echo 'Hello World!' printf Display something on the screen like C's printf. A more powerful echo. printf "Hello %x\n" 256 dialog A nice text pop-up dialog routine for scripts. dialog --msgbox "Mount the USB Key." 6 30 xmessage (X) X pop-up dialog. xmessage 'Shall we play a game?' dirname Returns the directory portion of a full pathname. Try dirname /usr/bin/foo In bash scripts it's faster to do this: pathname=/usr/bin/foo echo ${pathname%/*} basename Returns the filename portion of a full pathname. Try basename /usr/bin/foo.c In bash scripts it's faster to do this: pathname=/usr/bin/foo.c echo ${pathname##*/} line Copies a single line from stdin to stdout. Try name=$(line) or name=`line` to get a line from the user. logger Sends messages to the message log. mktemp Make a temporary filename. tempfile Make a temporary file. ncftp* Script oriented ftp commands. ncftpget, ncftpls, etc... Try "apropos ncftp" to see them all. sed Stream editor. Performs various transformations on files. Try: sed 's/the/bluefoot/' file to replace every "the" with "bluefoot" in "file". seq Generates a sequence of numbers. sleep Delays for a number of seconds. xargs Run a command using each line of a file as the arguments for each run. getopt Helps process command line options to a script. bash also has a built-in "getopts" command that can be used for this as well. Programming g++ C++ compiler. gcc C compiler. gcj Java compiler. clisp Common LISP compiler. gfortran FORTRAN compiler. gnat Ada compiler. as The portable GNU assembler. ld The GNU link editor. nasm The Netwide Assembler. ndisasm Disassembler. p2cc Pascal compiler. perl PERL language. python Python Programming Language ruby Ruby scripting language. slsh S-Lang script interpreter. make Builds only what needs to be built when changes are made to source code. strace Shows what system calls are being made by a program. Try "strace cat /dev/null". strace-graph Processes the output of "strace -f" and displays a fork graph. time A very crude profiler. c++filt C++ name demangler. demangle C++ name demangler. nm Lists symbols in an object (.o) file. Use "c++filt" or "demangle" to demangle C++ names. objdump Dumps various info from object (.o) files. size Displays sizes of sections of a .o or .a file. cscope C/C++ source browser. Faster and more powerful than rgrep. cxxmetric C/C++ metrics PERL script. Counts lines of code and comments. ctags Generates a source code name index for editors to allow jumping from an identifier's use to its definition. indent C code formatter. nc netcat utility. Reads and writes data over the network. Good for testing TCP/IP programs. oprofile Profiler. perror Converts an error code to text. cvs Version control system. Other available version control systems are RCS (man rcsintro), Subversion (svn), "git", and hg. Each has its own strengths and weaknesses. uuidgen Generates a UUID. xprop (X) Gives properties for a window.