The most wonderful thing about Linux-based systems is that you can use the command line in the terminal to manage the entire system. The advantage of using the command line is that you can use the same knowledge and skills to manage whichever Linux distribution you want.
For individual distributions and for the desktop Environment (DE), it is almost impossible to consistently use the graphical user interface (GUI) because they all provide their own user interface. To be clear, there are cases in which different distributions require different commands to perform certain tasks, but basically they are consistent in their thinking and purpose.
Use DNF on Fedora to manage system updates via the command line
In this article, we're going to discuss some of the basic commands that Linux users should master. I will show you how to use the command line to update the system, manage software, manipulate files, and switch to root, which will be done on three major distributions: Ubuntu (also including its plate and derivative versions, Debian), OpenSUSE, and Fedora.
Let's get started!
Keep your system safe and up to date
Linux is a security-based design, but in fact, any software has flaws that can lead to security breaches. So it's important to keep your system up to date. Think of it this way: running an outdated operating system is like sitting in a well-armed tank and the door is unlocked. Will the weapon protect you? Anyone can enter the open door and cause harm to you. Similarly, there is a bug in your system that is not patched, and these vulnerabilities can compromise your system. The open source community, unlike the patented world, responds fairly quickly to vulnerability patches, so if you keep the system up to date, you also get security assurances.
Watch the news site to learn about security vulnerabilities. If a vulnerability is found, understand it, and then update it the first time the patch comes out. However, in a production environment, you must run at least one update command every week. If you run a complex server, you need to be extra careful. Read the change log carefully to make sure that the update does not spoil your custom service.
Ubuntu: Keep in mind that you have to refresh the repository (that is, repos) before you upgrade your system or install any software. On Ubuntu, you can use the following command to update the system, and the first command to refresh the repository:
sudo apt-get update
After the warehouse update, you can now run the System Update command:
sudo apt-get upgrade
However, this command does not update the kernel and some other packages, so you must also run the following command:
sudo apt-get dist-upgrade
openSUSE: If you are on openSUSE, you can use the following command to update the system (as usual, the first command means to update the warehouse):
sudo Zypper Refresh sudo zypper up
Fedora: If you are on fedora, you can use the ' DNF ' command, which is ' similar ' to Zypper and Apt-get:
sudo DNF Update sudo DNF upgrade
Software Installation and Removal
You can install only those packages that are available in the warehouses that you have enabled on your system, and each release is accompanied by a number of official or third-party warehouses that are enabled by default.
Ubuntu: To install the package on Ubuntu, first update the warehouse, and then use the following statement:
sudo Install [Package_name]
Examples:
sudo Install GIMP
OpenSUSE: The command is this:
sudo Install [Package_name]
Fedora: Fedora has abandoned ' yum ' and is now replaced with ' DNF ', so the order is:
sudo Install [Package_name]
The process of removing the software is the same, as long as the ' install ' is changed to ' remove '.
Ubuntu:
sudo apt-get remove [package_name]
OpenSUSE:
sudo zypper remove [package_name]
Fedora:
sudo DNF remove [package_name]
How do I manage third-party software?
In a large developer community, these developers provide users with a lot of software. Different distributions have different mechanisms to make these third-party software available to users. Of course, it also depends on how developers make the software available to users, some developers provide binary packages, and others publish the software to the repository.
The PPA (Personal package archive) is used in many places in Ubuntu, but unfortunately it does not provide an built-in tool to help search for these PPA warehouses. Before installing the software, you will need to search the PPA via Google and then manually add the warehouse. Here's how to add a PPA to the system:
sudo add-apt-repository ppa:<repository-name>
Example: For example, I want to add the LibreOffice PPA to my system. I should google the PPA and then get the name of the repository from Launchpad, in this case it is "Libreoffice/ppa". Then, use the following command to add the PPA:
sudo add-apt-repository ppa:libreoffice/ppa
It will ask you to press ENTER to import the key. When you are finished, use the ' Update ' command to refresh the warehouse and then install the package.
openSUSE has an elegant solution for third-party applications. You can access software.opensuse.org, click Search and install the corresponding package, it will automatically add the corresponding warehouse to your system. If you want to add a warehouse manually, you can use this command:
sudo ar -f url_of_the_repo name_of_reposudoar -F http:// Download.opensuse.org/repositories/libreoffice:factory/opensuse_13.2/libreoffice:factory.repo LOF
Then, refresh the warehouse and install the software:
sudo Zypper Refresh sudo Install LibreOffice
Fedora users only need to add rpmfusion (including free software and non-free repositories), which contains a large number of applications. If you need to add the warehouse, the command is as follows:
DNF Config-manager--add-repo http://Www.example.com/example.repo
Some basic commands
I've written some articles about using the CLI to manage files on your system, and here are some basic commands that are often used on all distributions.
To copy a file or directory to a new location:
CP Path_of_file_1 path_of_the_directory_where_you_want_to_copy/
Copy all the files in a directory to a new location (note the slash and asterisk, which refers to all the files in that directory):
CP path_of_files/* path_of_the_directory_where_you_want_to_copy/
Move a file from one location to another (the trailing slash is said to be placed in the directory):
MV Path_of_file_1 path_of_the_directory_where_you_want_to_move/
Move all files from one location to another:
mv path_of_directory_where_files_are/* path_of_the_directory_where_you_want_to_move/
Delete a file:
RM Path_of_file
Delete a directory:
RM -R path_of_directory
Remove all contents from the directory and keep the directory folder intact:
RM -R path_of_directory/*
Create a new directory
To create a new directory, first go to the location where you want to create the directory. For example, you want to create a folder named ' Foundation ' in your documents directory. Let's change the directory using the CD (that is, change directory) command:
Cd/home/swapnil/documents
(replace ' Swapnil ' with user name in your system)
Then, use the mkdir command to create the directory:
mkdir Foundation
You can also create a directory from anywhere, by specifying the path to the directory. For example:
Mdkir/home/swapnil/documents/foundation
If you want to create the parent directory together, you can use the-P option. It creates all the directories in the specified path:
Mdkir-p/home/swapnil/documents/linux/foundation
Become root
You might need to be root, or a user with sudo power, to implement some administrative tasks, such as managing packages or making some modifications to the root directory or files under it. One example is editing the ' fstab ' file, which records the mounted hard drive. It is in the ' etc ' directory, and the directory is in the root directory, and you can only modify the file as a superuser. In most distributions, you can use ' Su ' to become root. For example, on openSUSE, I want to be root, because I want to work in the root directory, you can use one of the following commands:
sudo Su -
Or
Su -
The command will ask for a password, and then you will have root privileges. Remember: Don't run the system as root, unless you know what you're doing. It is also important to note that when you modify a directory or file with root, you change their owning relationship from that user or specific service to root. You must restore the ownership of these files, otherwise the service or user will not be able to access or write to those files. To change the user, the command is as follows:
sudo chown -R User: Group file or directory name
When you attach a partition on another distribution to the system, you may often need that action. When you try to access files on these partitions, you may encounter permissions to deny errors, and you can access them only by changing the owning relationship of those partitions. It is necessary to be careful not to change the permissions of the root directory or to have relationships.
These are the basic commands that Linux novices need. If you have any questions, or if you want us to cover a specific topic, please let us know in the comments below.
Linux commands that junior programmers should know