By Nicholas Brown.
Linux Mint commands are not only for maintaining servers without GUIs. They are useful to personal computer users as well because they enable you to get things done faster in some cases. This is a continuously updated list of Linux Mint commands that provides examples of how to use the commands so that you can hit the ground running. Linux Mint is Ubuntu-based, therefore many of these commands will also work on Debian, Ubuntu and other Debian-based distributions.
Disclaimer: Please note that you are solely responsible for what happens if you execute any of the Linux Mint commands herein, and that commands can do very different things dependent on the version of Linux Mint you are using, under which account the commands are executed among other reasons. Please exercise caution and do additional research if you are unsure about anything. Read Kompulsa’s disclaimer.
Note: ‘sudo’ is only required if you are not at a root shell.
Install Software, Uninstall, And Search For it
The following Linux Mint command installs an app on Linux Mint via command line without the GUI. This example installs ‘htop’, a system resource monitor.
sudo apt install htop
Note: It is best to run ‘sudo apt update’ first.
The above method installs software using the Aptitude package manager [PDF] on Linux Mint. You can also use ‘dpkg’ to install software from a ‘.deb’ package you downloaded from outside the official Linux Mint repositories. For example:
sudo dpkg -i appname.deb
What to do if you don’t know the exact name of the package? Let’s use ‘apt-cache search’ for that. See the following example in which we search for the Firefox development package.
sudo apt-cache search firefox dev
The output from the command shows the packages that most likely match that name:
firefox-dev - Safe and easy web browser from Mozilla - development files
cbindgen - Generates C bindings from Rust code
gnome-shell-extension-gsconnect-browsers - Browser support of KDE Connect implementation for GNOME Shell
html2wml - converts HTML pages to WML (WAP) or i-mode pages
libfirefox-marionette-perl - module to automate the Firefox browser with the Marionette protocol
There it is at the top! Now we can just install it by typing ‘sudo apt install firefox-dev’.
Uninstall A Package In Linux Mint Via Command Line
If you need to uninstall an app via command line on Linux Mint, use the command in the following example which removes ‘htop’. Note that this command does not cleanly remove all the files associated with an app.
sudo apt remove htop
If you need to remove a package cleanly, including its data and configuration, add ‘–purge’ to the command. Note that the ‘purge’ command is more aggressive in its attempts to remove associated files. Please be careful which symbols you use with this command, as it could yield unexpected results.
sudo apt remove --purge htop
Upgrade all packages on your system, except those that weren’t installed via the repositories
sudo apt upgrade
Editing Files Via Command Line In Linux Mint
There are many Linux Mint commands you can use to edit files. However, the one that is most likely to work (even if you have a fresh installation of the OS and haven’t gotten the chance to install anything yet) is Nano. Type ‘nano [filename]’. You can also use ‘vi’.
Viewing Files Via Command Line In Linux Mint
One of the most common Linux Mint commands to view files is ‘less’. See the example of the ‘less’ command’s usage below to open the file ‘filename.txt’:
You can also use ‘tail -f filename’ to view the end of a file. This is useful if you want to see the latest events in a large log file.
Locating Files In Linux Mint
You can find a file in Linux Mint that you need to edit or view using the ‘locate’ command as shown below. This is useful if you’re told to edit a certain configuration file but the person doesn’t tell you where it is on your machine. Note that you may need to run ‘sudo updatedb’ for it to work beforehand. Here’s an example of the ‘locate’ command’s usage:
That command locates the ‘pg_hba.conf’ configuration file used by PostgreSQL and tells you which directory it is in.
Authentication: Log In To A User Account On Linux Mint And Log Out
You can log into an account using the command line on Linux Mint by typing the ‘login’ command as shown in the following Linux authentication [PDF] example.
It will prompt you with ‘[computername] login:‘ at which point you would enter the username you want to login as. Press enter when done and then enter the password.
To log out, type the following to return to the previous account you were logged in as:
Create a user account via command line
sudo adduser new_user_name
Remove a user account
sudo deluser username
Change your password
View the groups your username is in on Linux Mint
You can view the groups a different user is in as shown below
Open the sudoers file
If you need to open the sudoers file in order to add a username or alter sudo privileges, you can use the following command:
List files, their owners and permissions
File And Directory Operations
You can create a directory in Linux Mint via command line as shown in the example below that creates a directory named ‘mystuff’. Format ‘mkdir [new-directory-name]’:
Enter a directory in Linux Mint via the command line
Format ‘cd [directoryname]’.
The result should look like this:
How to rename a file or move it
Format ‘mv [existing_file_name] [new_file_name]’. ‘mv’ means ‘move’.
mv testfile.txt newfilename.txt
How to view the contents of a directory
Enter the directory and use the following command:
How to remove a directory via the command line
Format: ‘rmdir [directory_name]’.
If the directory is not empty, you will get the following error:
rmdir: failed to remove 'mystuff': Directory not empty
You can get around this by typing ‘rm -rf’ instead.
rm -rf mystuff
How to delete a file via command line
How to copy files on Linux Mint
The Linux Mint command to copy a file is ‘cp’.
Format: ‘cp [source_file_to_copy] [new_file_name]’
cp testfile.txt testfilecopy.txt
How to move files on Linux Mint
The Linux Mint command to move a file is ‘mv’.
Format: ‘mv [source_file_to_move] [destination_directory/file_name]’
mv testfile.txt new_directory/testfile.txt
Download files via the command line
You can download files via the command line using cUrl or wget. See the two examples below.
curl -O websitename.com/filename
Shutdown Or Reboot
To reboot the operating system:
Shutdown the system now
sudo shutdown -h now
Check how long the system has been running/check uptime
Manage Processes And View System Resource Usage
View the RAM and CPU usage of each process
View virtual memory details
Shut down a process
The ‘pkill’ command sends the ‘SIGTERM’ command to the process to shut it down.
Check the status of a service to see if it is running, among other details
systemctl status process_name
Restart a service
sudo systemctl restart process_name
Stop a service
sudo systemctl stop process_name
Enable a service to run automatically at startup
sudo systemctl enable process_name
Stop a service from running on startup
sudo systemctl disable process_name
Get the IDs of a process
View the temperature of your CPU, SSD and other components
Clear the screen
Display information about your computer’s BIOS and motherboard
Create a RAMdisk on Linux
Execute the following commands in the sequence provided and change ‘4096M’ to the size in MB that you want the RAMdisk to be. Note that this disk is not persistent and will therefore be gone the next time you reboot.
sudo mkdir -p /media/ramdisk
sudo mount -t tmpfs -o size=4096M tmpfs /media/ramdisk
Connect to a server using SSH/SSH Login
Display your terminal command history
Delete your terminal command history