passwd
Change your password.
sudo
Gain temporary root privileges. Sudo stands for Super User DO. As in, do this with an administrative user’s privileges. You will retain these privileges for 15 minutes per terminal, which means you can run multiple sudo commands from that terminal without having to retype your password for each one. This example opens myfile.txt with root privileges, using a program called nano, which is my preferred terminal text editor. After editing a file with nano, press CTRL + o to overwrite. You can then change the filename if you wish and press ENTER to save. CTRL + x will close the file.
sudo passwd
Change your root password.
sudo !!
Run the last executed command with root privileges. Good for those times you forgot to add sudo to the beginning of a command.
su
Become root. (Super User)
sudo passwd -l root
This will disable/lock the root account.
You can still temporarily become root with your normal password by using this.
You can re-enable the root account by simply creating a new root password, just like above.
nautilus
Opens the nautilus file browser. (If you are using Linux Mint MATE, use caja instead. If you are using Linux Mint Cinnamon, use nemo instead.)
admin://
Run graphical programs with superuser privileges. Try to avoid using sudo for graphical programs because although it will run the program with superuser privileges, the program still sees the current home directory as your home directory. If the software writes configuration files, it’ll end up creating files in your home directory that are owned by the root user. You could potentially face other issues as well. The example below will correctly open a graphical program (in this case nautilus) with elevated privileges. The first admin session will ask you for your password twice. This is normal. After that you should only be prompted once each time until you reboot.
If you need elevated privileges to open a file with a graphical program, you have to add the full path to the file. (In the example below, we use the text editor gedit to open a text file (located in /home/username) with elevated privileges.
pwd
Print working directory. (Display the full path to the current directory.)
ls
List contents of the current directory.
List contents of the current directory. (Including hidden files.)
List contents of the current directory. (Pausing when screen fills. Pressing enter will then scroll one line at a time. Good for terminals with no scrollback.)
List contents of a chosen directory. (Replace /home/username/Desktop with your destination.)
As a shortcut, often times when a path contains /home/username, you can use ~ instead.
cd
Change directory.
If there are spaces in a path, put the path in quotations.
Navigate up one directory level.
Navigate to the previous directory. (Go back.)
Navigate to the root directory. (Not the same as becoming root.)
Navigate to your home directory.
exit
Exit the shell.
find
Search for a file in the current directory.
touch
Create an empty text file.
mkdir
Create an empty directory.
rmdir
Remove an empty directory.
rm
Remove a file.
Remove a directory recursively.
Force remove a file.
Force remove a directory recursively.
Force remove files in the current directory by filetype. (Replace .jpg with your chosen filetype.)
Force remove files in another directory by filetype. (Replace .jpg with your chosen filetype.)
mv
Move a file. (Replace ~/Desktop with your destination.)
Rename a file.
cp
Copy a file.
Copy a file and keep the same name. (Must move the copy to another directory. Replace ~/Desktop with your destination.)
Copy a directory recursively.
Copy a directory recursively and keep the same name. (Must move the copy to another directory. Replace ~/Desktop with your destination.)
grep
Print lines matching a pattern. (Example will print all lines in flowers.txt that contain the word roses.)
cat
View contents of a file.
wc -l
Count the number of lines in a file.
chmod +x
Make a file executable.
Then you can execute the file like this.
lsattr
List attributes of a file.
tar
Create a tarball from a file.
Create a tarball from a directory.
Extract a tarball.
Extract a tarball to another location. (Replace ~/Desktop with your destination.)
top
Display all running processes. (Press CTRL + c to halt this command.)
pidof
Find the process ID number of a running program.
kill
Kill a process by ID number. Replace XXXXX with the desired number.
killall
Kill a process by name.
arch
View your architecture type.
df -h
View used and available diskspace on filesystems.
free -m
Shows the amount of used and available RAM in megabytes.
acpi -t
Check system temperature and battery charge.
date
Display the date and time.
cal
Display a calendar.
w
See who is logged on and what they are doing.
who
See who is logged in.
whoami
Displays username of current user.
ifconfig
View information about the configured network interfaces.
Get your local ip address.
dig (Domain Information Groper)
Get your public ip address with dig.
You may have to add a – 4 to get this to work.
iwconfig
View wireless statistics.
iwlist scan
Scan for wireless networks.
lspci
List PCI devices.
lsusb
List USB devices.
which
Locate a command.
dpkg -i
Install a debian package. (If the package is in a different directory, use the full path to the package.)
wget -r
Download a website recursively.
clear
Clear the shell.
reset
Reload the shell.
history
View your bash history.
Clear your bash history.
apt-get
Retrieve new lists of packages.
Install new packages. (Replace gimp with your desired package.)
Remove packages.
Remove packages and configuration files.
Remove unused packages.
Erase downloaded archive files.
Erase old downloaded archive files.
Automatically answer yes to all prompts when using apt-get. (Just add a -y.)