Some useful commands for Ubuntu

Below are some useful commands for Ubuntu users.

Privileges Commands

sudo command – Run a command as root
sudo su – To open the root shell
sudo su user – To open shell as a user
sudo -k – Forget your password sudo
gksudo command – sudo visual dialog (GNOME)
kdesudo command – sudo visual dialog (KDE)
sudo visudo – To edit /etc/sudoers
gksudo nautilus – root file manager (GNOME)
kdesudo konqueror – root file manager (KDE)
passwd – Change your password. Need root privilege to execute the command.

Network Commands:

ifconfig – Displays information network
iwconfig – Displays information from wireless
sudo iwlist scan – Scan wireless networks

/etc/init.d/networking restart – Reset the network
vi /etc/network/interfaces – Manual network configuration
ifup interface – To bring online network interface
ifdown interface – To disable network interface

Display Commands:

/etc/init.d/gdm restart – To reset X (Gnome)
/etc/init.d/kdm restart – To reset X (KDE)
vi /etc/X11/xorg.conf – Show Configuration
dpkg-reconfigure – Reconfigure
xserver-xorg-phigh – Reset configuration X
Ctrl+Alt+Bksp – X display reset if frozen
Ctrl+Alt+FN – Switch to tty N
Ctrl+Alt+F7 – Switch back to X display

Service System Commands:

start service – Service to start work (Upstart)
stop service – service to stop working (Upstart)
status service – check if service is running (Upstart)
/etc/init.d/service start – Start service (SysV)
/etc/init.d/service stop – Stop service (SysV)
/etc/init.d/service status – Check service (SysV)
/etc/init.d/service restart – Reset service (SysV)
runlevel – To get current runlevel

Firewall related commands:

ufw enable – Turn on the firewall
ufw disable – Turn off the firewall
ufw default allow – Allow all connections by default
ufw default deny – Drop all connections by default
ufw status – Display Current rules
ufw allow port – To allow traffic on port
ufw deny port – To block a port
ufw deny from ip – To block an ip b

System Commands:

lsb_release -a – To Get the version of Ubuntu
uname -r – To get kernel version
uname -a – To get all the information kernel

Commands for Package Manager:

apt-get update – Refresh updates available
apt-get upgrade – To update all packages
apt-get dist-upgrade – To update the version
apt-get install pkg – To install a pkg
apt-get remove pkg – To uninstall a pkg
apt-get autoremove – Removing packages obsotletos
apt-get -f install – Try to fix packages
dpkg -configure -a – Try to fix a broken package
dpkg -i pkg.deb – To install file pkg.deb
vi /etc/apt/sources.list – List of repositories APT

Applications commands:

nautilus – To open File Manager (GNOME)
dolphin – To open File Manager (KDE)
konqueror – To open web browser (KDE)
kate – To open text editor (KDE)
gedit – To open text editor (GNOME)

The following two tabs change content below.

Tapas Mishra

Sr. Engineer (DevOps)
Loves to work on Opensource products. Having experience on Linux environment. Knowledge on Public cloud services like AWS, Rackspace, DigitalOcean, Linode. Please don't hesitate to give a comment on the posts. Your comments are my strength.

Leave a Reply