Apr 26, 2010

The most used shell commands for Ubuntu

shell commands
This is a list of Shell commands that can be very useful.

Privileges

sudo command – Run a command as root (administrator)
sudo -s – Open a shell as root
sudo -s -u user – Open a shell as user
sudo -k – Use it if you forget your password
gksudo command – Run command in GUI (GNOME)
kdesudo command – Run command in GUI (KDE)
sudo visudo – Change /etc/sudoers
gksudo nautilus – Launch the file manager (GNOME)
kdesudo konqueror – Launch the file manager (KDE)
passwd – Change password

Display

sudo /etc/init.d/gdm restart – Restart GDM (GNOME)
sudo /etc/init.d/kdm restart – Restart KDM (KDE)
sudo gedit /etc/X11/xorg.conf – Edit the configuration file Xorg
sudo dexconf – Reset xorg.conf
Ctrl+Alt+Bksp – Restart the X server when it crashes
Ctrl+Alt+FN – Switch to tty N
Ctrl+Alt+F7 – Back in the X server

System services

start service – Start a service as user
stop service – Stop a service as user
status service – Check if a service is running
/etc/init.d/service start – Start a service as root
/etc/init.d/service stop – Stop a service as root
/etc/init.d/service status – Check service
/etc/init.d/service restart – Restart a service as root
runlevel – Having the current runlevel

Package Manager

sudo apt-get update – Have updates available
sudo apt-get upgrade – Apply updates
sudo apt-get dist-upgrade – Upgrade to newer version of Ubuntu
sudo apt-get install pkg – Install a package
sudo apt-get purge pkg – Uninstall a package
sudo apt-get autoremove – Remove obsolete packages
sudo apt-get -f install – Forcing the installation of a package
sudo dpkg -i pkg.deb – Install the file package.Deb
sudo gedit /etc/apt/sources.list –  Edit the APT source file

Network

ifconfig – View information about the network configuration of the machine
iwconfig – View information on the wireless network
sudo iwlist scan – Scan for wireless networks
sudo /etc/init.d/networking restart – Restarts the network setup
/etc/network/interfaces – The configuration file interfaces
ifup interface – Enable an interface
ifdown interface – Disable interface

Firewall

ufw enable – Enable Firewall
ufw disable – Disable firewall
ufw default allow – Allow all connections by default
ufw default deny – Block all connections by default
ufw status – View the status of the firewall
ufw allow port – Allow port
ufw deny port – Block port
ufw deny from ip – Block an IP address

System
lsb_release -a – Show version of Ubuntu
uname -r – Show Kernel version
uname -a – Show information about the installed Kernel

If you know other commands please feel free to post a comment or email me so I can complete the list.

Practical Guide to Linux Commands, Editors, and Shell Programming, A (2nd Edition)