Other Parts of This Series:
- Part 8: DevOps - Step By Step Learning : Part 8 (Linux Command for File, Directory and Text Manipulation)
DevOps Linux Package, User, Process Management (Photo Credit: Unsplash)
Story:
Rasel already learned commands to manage files, directories, and contents in them without needing any UI and only via CLI. To run an application (maybe frontend, backend, database, or any other program), we need to install many dependencies like other software/applications, packages, or libraries. So Rasel now needs to learn to manage packages via command. Also, for safety, security, and operational purposes, user and permission management is another mission-critical task, so you need to learn this as well. To make operational life easy, efficient, and robust, Linux process and system management is a very important part that should be learned at any cost as a DevOps professional. Rasel wanted to explore all these topics and did so.
Linux Package Management:
In linux ecosystem, package manager helps to install, uninstall, update and remove software. From the high level linux package manager can be 2 type. They are:
- .DEB based (DPKG/APT/APT-GET): Ubuntu, Debian, linux Mint
- .RPM based (YUM): Red hat enterprise linux, Centos, Fedora
Some important commands of .DEB based package manager are:
| |
This install the the given named package.
| |
This update the package list.
| |
This upgrade all the package in list.
| |
This remove or uninstall the given named package.
| |
This gives the package list.
| |
This search the given name package in the list.
Example:
Some important commands of .RPM based package manager are:
| |
This install the the given named package.
| |
This update the package list.
| |
This upgrade all the package in list.
| |
This remove or uninstall the given named package.
| |
This gives the package list.
Example:
Linux User and Permission Management:
Linux prioritize the security and separation of concern by default. That’s why it gives commands to create, manage user, user group and manage permission between them. By default, linux has a super user who called root user and able to perform all kinds of operation without any restriction.
Super user command:
| |
This perform the given command as root user. Means when we add prefix sudo, then it tells linux perform super (s) user (u) do.
Commands for create user and group:
| |
This creates a new user with given name.
| |
This delete the user with given name.
| |
This creates a group with given name.
| |
This attach the given user into given group name.
Example:
Commands for manage file permissions:
Linux file permission has 3 kinds: Read (r), Write (w) and Execute (x). So we need to assign these 3 type of permission separately.
| |
This set permissions to the file with given name.
| |
This change owner and group with given name for the given named file.
Example:
Linux System Process Management:
- A process is an instance of a running program. It’s the active state of a program, rather than the program itself, which is a collection of instructions stored on disk.
- System processes are the background tasks that keep the operating system running smoothly. They include things like daemons, which provide essential services, and kernel threads, which are part of the kernel.
- User processes are the applications and commands that you initiate through a terminal or graphical interface.
- Processes can exist in various states, such as running, sleeping, stopped, or zombie, each representing a different stage of execution.
Commands for process management:
| |
This gives list of all process.
| |
This works as the real-time process viewer.
| |
This like top but more interactive viewer. But need to install separately.
| |
This list the process but only with the given process name.
| |
This kill the process with given id.
| |
This forcefully kill the process with given id.
| |
This kill the process with given name.
| |
This runs the sh or script file as background task.
| |
This gives list of all background process.
| |
This bring job 1 to foreground.
Example:
Summary:
Linux package management helps you install, update, and remove software easily using tools like apt or yum. Managing users and permissions is important for security and you can create users, groups, and set file access rights using commands like adduser, chmod, chown. This ensures only the right people can access or modify files. Process management lets you view and control running programs on your system using tools like ps, top, kill. These tools help you monitor system performance and stop unresponsive tasks.