Debian Commands Cheat Sheet.

by David Sudjiman ~ December 13th, 2005. Filed under: Linux.

These are the commands that people usually use in Debian (or Linux) for day-to-day task. Not the most complete one, though. Fell free to add if you have any.

ls -l
This the most common command that all *nix users use to show the file(s) in list format.

rm -rf <filename(s)>
To delete a file, use this command. Be careful, no retrieval will help you to get your file.

/etc/init.d/networking restart
I use to do this just to restart my networking everytime I make some changes on /etc/network/interfaces or just to restart ethernet to get a new IP from DHCP server.

ping <hostname>

To make sure that you’re connected to the internet, use this command to test your connection to <hostname>. Example:

$ ping www.google.com
PING www.l.google.com (66.102.7.104) 56(84) bytes of data.
64 bytes from 66.102.7.104: icmp_seq=1 ttl=241 time=166 ms
64 bytes from 66.102.7.104: icmp_seq=2 ttl=241 time=166 ms
64 bytes from 66.102.7.104: icmp_seq=3 ttl=241 time=167 ms
64 bytes from 66.102.7.104: icmp_seq=4 ttl=241 time=168 ms
64 bytes from 66.102.7.104: icmp_seq=5 ttl=241 time=166 ms

--- www.l.google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4003ms
rtt min/avg/max/mdev = 166.421/167.017/168.146/0.683 ms

cat <filename>
To show the content of <filename>

dpkg-reconfigure <package_name>
Debian uses this command to configure some packages configuration. For example, if you want to configure exim email server on your debian, you can use dpkg-reconfigure exim4-config or for your XWindow you can use dpkg-reconfigure xserver-xfree86

perl -p -i -e ’s/<A>/<B>/g’ <filename(s)>
This is a small perl command to change the content of your file(s). For example, you want to change your .procmail recipe from To to (To|Cc).

$ cat .procmail
:0:
* ^To:.+john_doe\@hotmail\.com
/dev/null
$ perl -p -i -e 's/To/(To|Cc)/g' .procmail
$ cat .procmail
:0:
* ^To:.+john_doe\@hotmail\.com
/dev/null

apt-get install <package_name>
Debian provides a very nice nice apt-get command to install
a package. Once you execute this command, you just sit still and relax
without have to worry about dependencies. apt-get will
install the package and its dependencies automatically.

apt-get update && apt-get upgrade
To make sure you have the latest package list, use the command apt-get update and to upgrade your package to the latest version use command apt-get upgrade or you can just use both command in one single line.

apt-cache search <package_name>
If you want to know what is the complete package name for package wget for example, you can use command apt-cache search wget and Debian will show you any package with the word wget in it.

$ apt-cache search wget
abcde - A Better CD Encoder
aget - Multithreaded HTTP Download Accelerator
apt-zip - Update a non-networked computer using apt and removable media
axel - A light download accelerator - Console version
axel-kapt - A light download accelerator - Console version front-end
devscripts - Scripts to make the life of a Debian Package maintainer easier
emacs-goodies-el - Miscellaneous add-ons for Emacs
gtm - Multiple files transfer manager
gwget - GNOME front-end for wget
ja-trans - Japanese gettext message files
libapache-mod-auth-useragent - blocks parts of service for certain user agents
mirror - Keeps FTP archives up-to-date
puf - Parallel URL fetcher
smbget - Downloader for the SMB/CIFS protocol
snarf - A command-line URL grabber
wget - retrieves files from the web
wget-el - an interface for wget on Emacsen
wput - A tiny wget-like ftp-client for uploading files
zope-zshell - command line interface to Zope
setiathome - SETI@Home Client (install package)

apt-cache show <filename>
This will show you the complete information of <filename>.

$ apt-cache show wget
Package: wget
Priority: optional
Section: web
Installed-Size: 1460
Maintainer: Noèl Köthe 
Architecture: i386
Version: 1.9.1-12
Depends: libc6 (>= 2.3.2.ds1-21), libssl0.9.7
Conflicts: wget-ssl
Filename: pool/main/w/wget/wget_1.9.1-12_i386.deb
Size: 426438
MD5sum: 5dbc48f9b105b7f5fb894a714ea31911
Description: retrieves files from the web
 Wget is a network utility to retrieve files from the Web
 using http and ftp, the two most widely used Internet
 protocols. It works non-interactively, so it will work in
 the background, after having logged off. The program supports
 recursive retrieval of web-authoring pages as well as ftp
 sites — you can use wget to make mirrors of archives and
 home pages or to travel the Web like a WWW robot.
 .
 Wget works particularly well with slow or unstable connections
 by continuing to retrieve a document until the document is fully
 downloaded. Re-getting files from where it left off works on
 servers (both http and ftp) that support it. Both http and ftp
 retrievals can be time stamped, so wget can see if the remote
 file has changed since the last retrieval and automatically
 retrieve the new version if it has.
 .
 Wget supports proxy servers; this can lighten the network load,
 speed up retrieval, and provide access behind firewalls.
 .
 http://www.gnu.org/software/wget/

apt-get remove <package>
To uninstall package, use the above command.

dpkg -P <package>
Sometime some configuration file(s) are not completely removed. Use this command to clean all the file(s) related to the package

dpkg -l | grep <>
To see what kind of package(s) is or are installed use the command

dpkg -l or if you need to know whether you have installed package X or not you can simply use dpkg -l | grep X

grep <word> <filename>
If you need to know whether in <filename> contains this <word> you can use this command.

:> <filename>
To empty or erase the content of <filename>

updatedb
This to be used together with locate command. updatedb command is to update the file list database so command locate can just find the file much quicker by looking its database (or you may call it metadata).

locate <filename>
This is for finding <filename> using file list database.

du -h
If you can’t see how big the size of your directory is using ls -l, use this command.

df -h
This is to list the mounted partition available on your computer.

traceroute <hostname|fqdn>
To check how ‘far’ your computer from <hostname|fqdn>. Basically this command will trace your data packets and list each of the router in between.

Leave a Reply