Skip to main content
  • Place orders quickly and easily
  • View orders and track your shipping status
  • Enjoy members-only rewards and discounts
  • Create and access a list of your products
Some article numbers may have changed. If this isn't what you're looking for, try searching all articles. Search articles

Common Ubuntu Linux Terminal Commands Explained

Summary: The following article provides information about the common terminal commands in use with Ubuntu Linux.

This article applies to This article does not apply to This article is not tied to any specific product. Not all product versions are identified in this article.

Instructions

Table of Contents:

  1. Basic Control Commands
  2. Basic User and System Commands
  3. Basic Drives and Rights Commands
  4. Basic Network Commands

Basic Control Commands

 

Terminal Commands are instructions that you can use while in the Ubuntu terminal application to accomplish any tasks on your computer. I have subdivided the commands into smaller tables to make their uses clearer and to aid in using these articles as a reference point.

 
Command Effect Other Info
cd Change Directory With this command, you can navigate through the Filesystem (Typing cd or cd~ takes you to the home folder, which is the default starting position in terminal)
cd/ Go to the root directory  
cd.. Up one directory level  
cd- Back to previous directory  
pwd Print working directory This displays your location in the Filesystem
bash GNU Bourne-Again Shell  
break Exit from a loop  
case Conditionally perform a command  
clear Clear terminal screen  
continue Resume the next iteration of a loop  
cron Daemon to run scheduled commands  
crontab Schedule a command to run later  
echo Display a message on screen  
enable Enable and disable integrated shell commands  
env Environment Variables  
eval Evaluate several commands or arguments  
expect Automate applications accessed over a terminal  
export Set an environment variable  
expr Evaluate expressions  
false Do nothing, unsuccessfully  
for Expand words and run commands  
hash Remember the full pathname of a name argument  
hostname Print or set the devices name  
if Conditionally perform a command  
jobs List active jobs  
join Join lines on a common field  
journalctl View the system logs and troubleshoot problems Provides information about service logs, kernel messages, and more
local Create variables  
logout Exit a login shell  
more Display output one screen at a time  
nice Set the priority of a command or job  
nohup Run a command immune to hang-ups  
notify-send Send desktop notifications  
op Operator access  
readarray Read from stdin into an array variable  
readonly Mark variables or functions as read-only  
reboot Reboot the device  
return Exit a shell function  
sed Stream editor  
select Accept keyboard input  
set Manipulates shell variables and functions  
shift Shift positional parameters  
shopt Shell options  
shutdown Shut down or restart Linux  
sleep Delay for a specified time  
ssh Secure shell client Remote login program
suspend Suspend execution of this shell  
sync Synchronize data on disk with memory  
test Evaluate a conditional expression  
trap Run a command when a signal is set  
true Do nothing, successfully  
type Describe a command  
unshar Unpack shell scripts  
until Run commands Until error
vmstat Report virtual memory statistics  
watch Run or display a program periodically  
while Runs commands  
write Send a message to another user  
xargs Run utility, passing constructed argument lists  
### Lets you remark or comment without disturbing the terminal  
while Runs commands  

Managing files and text are commands that directly affect the files and the text that are stored and used on your computer. The Dash and the Windows Explorer tool are well-known Graphical User Interface (GUI) versions of this tool.

 
Command Effect Other Info
cp Copy Lets you copy a file, to do so add the name of the file you want to copy along with the command. Where the file is located in the directory that you have browsed to. Otherwise type cp~/< file path > in order to specify where the file you want to copy is located.
ls List Lists all the files in the current directory
ls~ Lists files in the home directory Adding a folder name shows a list of all the files in that specific folder. For example: ls~/desktop shows you the files in the desktop folder
mkdir Make a directory Lets you create a directory. For example: mkdir private files create a new directory named private files that are located in the home directory. Unless you browsed to another directory or specified another path.
mv Move You can rename or move a file with this command. If you want to rename the file sunny today, you may want to type mv sunny day. This requires that you have browsed to the correct directory or that you specified the correct file path. When you type mv day ~/Desktop, the file day is moved from home to Desktop. However, if you want to rename the file as well, as the new file name next to the current name in the command.
rm Remove Removes a file, specify the file path, or file name
rmdir Remove directory Removes an empty directory
rm -r Remove recursively Removes a directory along with its content
grep Search for text strings  
head Display start of file  
less Display part of the file  
tail Display end of file  
apropos Searches help manual pages  
aspell Spell Checker  
awk Find and Replace text Database sort, validate, or index
cmp Compare two files  
comm Compare two sorted files line by line  
csplit Split a file into context-determined pieces  
cut Divide a file into two separate pieces  
cksum Print the Cyclic Redundancy Check (CRC) checksum and byte counts  
find Search for files that meet set criteria  
fmt Format paragraph text  
fold Wrap text to a specific width  
dir Briefly list directory contents  
dircolors Color setup for ls  
dirname Convert a full pathname to a path  
dirs Display a list of remembered directories  
cat Display the contents of a file  
bzip2 Compress or decompress named files  
chroot Run a command with a different root directory  
fgrep Search files for lines that match a fixed string  
fuser Identify or Kill the process that is accessing a file  
gawk Find and replace text within files  
gzip Compress or decompress Name files  
ln Makes links between files  
locate Find files  
look Display lines beginning with a given string  
lpr Off-line print  
lpc Control program for the line printer  
lprm Remove jobs from the print queue  
lprint Print a file  
lprintd Cancel a print job  
lprintq List of the print queue  
lsof List open files  
vdir Verbosely list directory contents ls -| -b
v Verbosely list directory contents ls -| -b
vi Text editor  
uuencode Decode a file Decode a file using uuencode
uuencode Encode a file Encode a file using uuencode
tty Print filename of terminal on stdin  
touch Change file timestamps  
expand Convert tabs to spaces  
import Capture an x server screen and save the image to a file  
install Copy files and set attributes  
fg Send job to foreground  
bg Send job to background  
nl Number the lines and write the files  
open Open a file in its default application  
paste Merge lines of files  
pathchk Check file name portability  
popd Restore the previous value of the current directory  
pr Prepare files for printing  
printcap Printer capability database  
printenv Print environment variables  
printf Format and print data  
pushd Save and then change the current directory  
rcp Copy files between two machines  
read Read a line from standard input  
rename Rename files  
remsync Synchronize remote files using email  
mmb Mass move and rename files  
mtools Manipulate MS-DOS files  
rev Reverse lines in a file  
rsync Remote copy a file Synchronize file trees
sdiff Merge two files interactively  
scp Secure copy  
sftp Secure file transfer program  
slocate Find file  
sort Sort text files  
split Split a file into fixed size pieces  
sum Print a checksum for a file  
tee Redirect output to multiple files  
tsort Topological sort  
unmask Creation mask for the user file  
source Run commands from file  
symlink Makes a new name for a file  
tr Translate, squeeze and/or delete  
uniq Uniquify files  
wc Print byte, word, and line counts  
whereis Search the users $path, man pages, and source files for a program  
which Search the users $path for a program file  
wget Retrieve web pages or files  
unexpand Convert space to tabs  
yes Print a string until interrupted  
xdg-open Open a file or URL in the users preferred application  
dmesg Print kernel and driver messages  

Basic User and System Commands

 

These commands enable you to manage, configure, troubleshoot, and reset the User and Group settings on your Ubuntu device.

 
Command Effect Other Info
passwd Create a password  
groupadd Add a group  
groupmod Modify a group  
chgrp Change group  
groupdel Delete group  
adduser Add a user to the device  
addgroup Add a group to the device  
alias Create an alias  
useradd Create a new user account  
usermod Modify user account  
users List users that are logged in  
chmod Change access permissions  
chown Change file owner and group  
groups Print group names a user is in  
id Print user and group ids  
logname Print the login name  
su Substitute another user identity  
times User and computer times  
who Print all usernames that are logged in  
timedatectl Manage devices time and date settings. (Includes time zones and synchronization with Network Time Protocol (NTP) servers.)  
whoami Print the current user id and name id -un

The following commands deal with device-specific programs and information.

 
Command Effect Other Info
cal Calendar Display the calendar
date Date Display the date
dc Desk Calculator Calculator
fsck File System Check  
bc Arbitrary precision calculator language  
kill  Stop a process from running  
killall Kill processes by name  
let Perform arithmetic on shell variables  
make Recompile a group of programs  
pkill Stop processes from running  
ps Process status  
seq Print numeric sequences  
units Convert units from one scale to another  

Packages are the Ubuntu default method of loading and updating new applications and files. These commands allow for management and configuration of the packages that were downloaded.

 
Command Effect Other Info
apt -get Search for and Install software packages  
aptitude Search for and Install software packages  
apt -get update Refresh available updates  
apt - get upgrade Upgrade all packages  
apt -get dist-upgrade Upgrade with package replacements Upgrade Ubuntu Version
apt -get install pkgname Install the package by name  
apt -get purge pkgname Uninstall the package by name  
apt -get autoremove Remove obsolete packages  
apt -get -f install Try to fix broken packages  
dpkg -configure -a Try to fix broken packages  
dpkg -i pkg.deb Install file pkg.deb  

These commands give you a direct way to manage the services on your Ubuntu device.

 
Command Effect Other Info
start service Start a job service Upstart
stop service Stop job service Upstart
status service Check if the service is running Upstart
/etc/init.d/service start Start service SysV
/etc/init.d/service stop Stop service SysV
/etc/init.d/service restart Restart service Sysv
/etc/init.d/service check Check service SysV
systemctl New Service Command This replaced service
runlevel Get the current runlevel  

Basic Drives and Rights Commands

 

Managing the drives and formats means that you can affect the peripherals that are attached to your computer. Whether these be multiple Hard disk drives, removable media or other devices. They allow you to manage and configure these devices at the command-line level.

 
Command Effect Other Info
mount Mount a drive  
unmount Unmount a drive  
fdisk Format disk  
cfdisk Partition table editor for Linux  
dd Duplicate disk Convert and copy a file, write disk headers, or boot records
ddrescue Data recovery tool  
declare Declare variables and assign attributes  
df Disk free space Displays how much disk space on every mounted partition that is occupied (df uses MB and GB instead of blocks)
du Directory usage Displays how much space a given directory plus all its subdirectories uses
du -s Directory usage summary  
du -h Directory usage basic info This translates the information into a basic non-tech format
free How much free space is available This tells you how much free space is available for use
free -m Shows free space statistics Shows the statistics in MB
uname -a Get all kernel information  
uname -r Get kernel information  
lsb_release -a Prints information about your Linux distro  
top Start device monitoring This initiates monitoring, viewing RAM, CPU and swap usage, plus the total running processes
htop Provides a real-time monitor of computer resources This replaced top
q Stop device monitoring  
diff Display the difference between two files  
diff3 Display the difference between three files  
 
Note: Most of the following commands must be prefaced with the sudo command. This elevates privileges to the root-user administrative level temporarily. Which is necessary when working with directories or files that your user account does not own. When using sudo, you are prompted for your password. Only users with sudo (administrative) privileges can use this command.
 
Command Effect Other Info
history List of all commands user The history command shows a long list of commands that you have typed. Each command is displayed next to a number. You can type | x to run a previously typed command from the list (replace the X with a number). If your history output is too long, then use history | less for a scrollable list
REISUB Reboot computer Hold down both the ALT and PRINTSCRN keys while typing this to restart the computer
apt -get Application Used to install, removed, upgrade, and more
file Type checking of one or more files  
sleep Delay commands Wait x seconds to go to the next command
pidof Get the Process ID (PID) PID given in readable format
ps System monitor for command line Also good for scripts
cat Print file in command line  
crontab Time drive events  
man Help manual Open the manual of programs, displays the command manual
man man Manual about Manual Help page about using help page
man intro A brief list of commands When you need information about a command, type < command name >-h or < command name  >--help, if the first rule did not work. You see that some command lines may not associate -h with --help.
info info Introduction to info pages  
basename Strip directory and suffixes from filenames  
eject Eject removable media  
fdformat Low-level format Format a floppy disk (FD)
mkisofs Create a hybrid Filesystem  
format Format disks or tapes  
mknod Make block or character special files  
quotactl Set disk quotas  
quotacheck Scan a file system for disk usage  
quota Display disk usage and limits  
tar Tape archiver  
ram RAM disk device  

The rights to files and directories and the ability to change them are required at an administrator level. These can be used to change or repair existing files or to stop other files or directories from inexperienced users causing damage.

 
Command Effect Other Info
chmod Change Mode  
su Switch User  
ulimit Limit user resources  
unalias Remove an alias  
unset Remove variable or function names  
function Define Function macros  

Elevated privileges are what Ubuntu calls Administrator Rights. You must run these commands when you must change things on your device at a high enough level. The windows equivalent would be opening a command prompt as an administrator.

 
Command Effect Other Info
sudo Elevated privileges Running commands with elevated privileges - < superuser do >; a common expression which indicates that the action taken must be verified with the admin password
sudo -r Open root shell as user  
sudo -r -u Open shell as user  
sudo -k Forget sudo passwords  

Basic Network Commands

 

These commands deal with configuring and troubleshooting Network connections on your device. This includes wired and wireless connections.

 
Command Effect Other Info
chkconfig Check activated services  
ping Test network connections  
ftp File Transfer Protocol  
host Check IP of Domain  
ifconfig Configure network devices  
ip Configure network devices This has replaced ifconfig
iwconfig Show wireless information  
iw Show wireless information This has replaced iwconfig
sudo iwlist scan Scan for wireless networks  
ifup eth0 Bring interface eth0 online  
ifdown eth0 Display the eth0 interface  
netstat Display routing table  
ss Display routing table This has replaced netstat
route Set routes  
telnet Connect to Telnet  
traceroute Display route  
dig Domain Name Server (DNS) lookup  
ethtool Ethernet card settings  
mkfifo Make First In First Out (FIFO)s Named pipes
mtr Network diagnostics traceroute/ping
nslookup Query Internet name servers interactively  
screen Multiplex terminal Run remote shells using ssh
strace Trace computer calls and signals  

These commands deal with the Ubuntu firewall management and configuration.

 
Command Effect Other Info
ufw enable Turn on the firewall  
ufw disable Turn off firewall  
ufw default allow Allow all connections by default  
ufw default deny Deny all connections by default  
ufw status Cyrrebt status and rules  
ufw allow port Allow traffic on port  
ufw deny port Deny traffic on port  
ufw deny from ip Block IP Address  

Additional Information

 

Note:
Software support is by Canonical through the following methods:
Dell provides Technical Support:

Affected Products

Inspiron, Latitude, Vostro, XPS, Fixed Workstations
Article Properties
Article Number: 000123980
Article Type: How To
Last Modified: 21 يونيو 2024
Version:  5
Find answers to your questions from other Dell users
Support Services
Check if your device is covered by Support Services.