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 http://securityandrisk.blogspot.fr
(you can also try with http://securityandrisk.blogspot.de/search?max-results=2000)
- 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
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1
- You need to define a DNS servers in Linux via a config file and not via NetworkManager? Then this is the location and syntax
/etc/resolv.conf
nameserver 8.8.8.8
- You need to declare the name of your host via a config file? Then this is the location and syntax
/etc/hosts
127.0.0.1 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
sudo ifconfig
- 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 |