Linux commands hodgepodge (II)

Again this post is an unusual one. The second unusual one after the first one on linux command lines. The reader will not find a series of paragraphs with a ine of thought in it but rather a collection of command lines and related telegraphic recommendations for some aspects of the Linux Universe (e.g. Ubuntu).

Happy command line experience!

- To install a debian package via command line
# dpkg -i deb package

- To list the packages we have installed
dpkg -l

- To indetify whether a package name is installed
dpkg -l | grep package name

- To get rid of configuration files from packages that are not installed anymore
dpkg --list |grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge

The legend of the dpkg --list output can be found here.

- To know which Ubuntu is installed
lsb_release -a

- To know which linux kernel is installed
uname -a

- To remove a debian package (leaving the configuration files)
#apt-get remove packagename

- To remove a debian package and the related configuration files
#apt-get purge packagename

- To find which files have being created in the last 24 hours
find -mtime 0

- To download a blogspot blog
wget -m

(you can also try with

- To know the status of networking interfaces
#rfkill list

- To unlock one of them
#rfkill unblock number

- To start the firestarter firewall
#/etc/init.d/firestarter start

- To dump all traffic seen by the network interface not sent to or by your box and not part of multicast or broadcast
#tcpdump -i eth0 net 192.168.x.0/24 and not host 192.168.x.a and not multicast and not broadcast

- To identify active Internet connections (only servers)
#netstat -tulpn

- Nice and easy way to identify the networks this box has been
#grep -i NetworkManager /var/log/syslog

- To edit the scheduler in linux
crontab -e

- The basic way to use vi or vim:

To move into the text: h l j k
To replace a character under cursor with c rc
To insert before or after the cursor i a
To open a new line below or above the current line o O
To delete a character x
To undo the last command u
To select a line yy
To paste a line p P
To write and exit :wq
To toggle edit/meta mode ESC

When installing packages, you will find the config files in /etc/apt/apt/conf and the binary files in /usr/bin

- You need to define a network interface in Linux via a config file and not via NetworkManager? Then this is the location and syntax
edit /etc/network/interfaces
in the file
iface eth0 inet static

- You need to define a DNS servers in Linux via a config file and not via NetworkManager? Then this is the location and syntax

- You need to declare the name of your host via a config file? Then this is the location and syntax
/etc/hosts localhost

- You need to swith on/off a network interface in Linux via the command line and not via NetworkManager?
Then you can use ifup/ifdown or
sudo ifconfig down
sudo ifconfig up

- A quick way to become root?
sudo su -

- Need to get processes associated with a name
ps aux | grep name

- A non-elegant way to kill a process?
killall processname

- You need to get rid of the disturbing sound with typing
sudo modprobe –r pcspkr

Command lines enlighten us