Discover DevOps roles and learn Linux from basics to advanced at DevOpsRoles.com. Detailed guides and in-depth articles to master Linux for DevOps careers.
In this tutorial, I using the rpm command to query lists the packages installed on the system. How do I use “rpm query installed packages in Centos, RHEL, and Fedora“. Linux the essential for DevOps Roles.
RPM query installed packages
List of the only package installed your system.
$ rpm -qa --qf "%{NAME}\n"
Example, List of the package installed on “Server A”. After then, How to install the package from “Server A” for “Server B”
Server A $rpm -qa --qf "%{NAME}\n" > packaged.list
Server B #xargs yum -y < packaged.list
Display the package names, versions and releases with this command
Thought the article, How to use “RPM query installed packages in Centos RHEL and Fedora” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, How to solve bad interpreter when running the shell exit with “bad interpreter: /bin/sh^M: no such file or directory“. I will be using three methods. Linux the essential for DevOps Roles.
bad interpreter: /bin/sh^M: no such file or directory fixed
Method 1: Using vim editor
Open vim and insert the following command
:set fileformat=unix
:x
Or
:set ff=unix
:x
Method 2: Using sed command
[huupv@huupv devopsroles]$ sed -i 's/\r//' FILE_NAME
Method 3: I Using dos2unix command
[huupv@huupv devopsroles]$ dos2unix FILE_NAME
Conclusion
Thought the article, You have solved the problem “bad interpreter: /bin/sh^M: no such file or directory” as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!
This guide will walk you through how to kill specific processes in Linux, from basic commands to advanced techniques, with practical examples. Whether you’re new to Linux or looking to refine your skills, mastering these commands can save you time and enhance system stability.
Linux is a powerful and flexible operating system, used in a variety of environments, from personal desktops to complex server systems. One essential aspect of managing a Linux system effectively is understanding how to handle running processes, especially when they behave unexpectedly or consume too many resources.
Why Kill Processes in Linux?
Processes in Linux are essentially tasks or programs that are currently running on the system. Sometimes, these processes can become unresponsive, hog system resources, or even cause the system to crash. In such cases, killing the process becomes essential to free up resources and maintain the smooth operation of the system. This article provides a comprehensive look at various ways to kill processes based on different criteria, allowing you to manage your Linux system with greater efficiency.
How to View Running Processes
Before killing any process, it’s crucial to know how to view the processes running on your system. You can use several commands to list active processes.
Using ps
The ps command provides a static snapshot of all currently running processes:
ps aux
a: Shows processes for all users.
u: Displays processes in a user-oriented format.
x: Lists processes not connected to a terminal.
Using top and htop
The top and htop commands give a real-time view of running processes.
top
For a more user-friendly interface, install and use htop:
htop
kill specific processes in Linux
For example, kill all PID of the browser Firefox. But not kill line “grep –color=auto firefox” as the picture below
Use ps command with “-ef” option the display PID of browser Firefox.
Managing processes in Linux is a fundamental skill that improves your efficiency and control over the system. This guide has covered essential commands for killing specific processes, from using kill and pkill to more advanced techniques. Practice these commands to confidently handle any unresponsive or resource-consuming processes on your system. Remember to exercise caution, especially with kill -9, and ensure you understand the implications of terminating critical processes. By mastering these techniques, you’ll be better equipped to maintain a smooth-running Linux environment. Thank you for reading the DevopsRoles page!
How to use the SCP command in Linux to copy a file from one server to another. it is used to securely copy a file to or from a remote server.
Discover the simplicity and power of using the SCP command in Linux for secure file transfers. This tutorial will guide you through various examples of how to utilize SCP to copy files and directories between servers securely. Whether you are a beginner or an experienced administrator, mastering the SCP command is crucial for managing remote file transfers efficiently.
SCP command example
Copy file from one client location to another server location
With the SCP command, transferring files between servers becomes a seamless task. This guide has shown you several practical examples to help you understand how to use SCP effectively. By integrating these techniques into your workflow, you’ll enhance your server management skills and ensure secure data handling. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, How do I list all services running in Linux distribution? List running service on Ubuntu Or Systemd service management. Linux the essential for DevOps Roles.
Linux list services
Systemd service management
Listing services
Listing running services.
[huupv@huupv devopsroles]$ systemctl
The screen output terminal
Listing the “failed” services
[huupv@huupv devopsroles]$ systemctl --failed
The screen output terminal
Managing targets
To find the default target for your system.
[huupv@huupv devopsroles]$ systemctl get-default
Setting the default target for your system
$ sudo systemctl set-default <target-name>
Managing to autostart of services
Showing a service is enabled on system boot.
$ sudo systemctl is-enabled [service-name]
To show a service is currently active (running).
$ sudo systemctl is-active [service-name]
Enabling a service on system boot.
$ sudo systemctl enable [service-name]
Disabling a service on system boot.
$ sudo systemctl disable [service-name]
Managing services at runtime
Starting a service
$ systemctl start [service-name]
Stopping a service
$ systemctl stop [service-name]
Restarting a service
$ sudo systemctl restart [service-name]
To request the service to reload its configuration.
$ sudo systemctl reload [service-name]
Showing the current status of a service
$ sudo systemctl status [service-name]
To restart your Systemd.
$ sudo systemctl daemon-reload
List running services on the Ubuntu distribution
To get the list of the services on your system.
$ service --status-all
Conclusion
Through the article, you can use Linux list services as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, How do I use the tar command the compress and extract files and folders in Linux? Linux the essential for DevOps Roles.
The tar command in Linux is used for creating and manipulating tar archives, which are commonly used for bundling multiple files and directories into a single file. Here are a few examples of how to use the tar command.
The syntax tar command
tar [Options] your_tar_name.tar source_tar
Options
-c –create Create a new archive. -x –extract Extract files from an archive. -t –list List the contents of an archive. -f –file=ARCHIVE Use archive file or directories ARCHIVE. -v –verbose Verbosely list files processed. -a –auto-compress Use archive suffix to determine the compression program. -j –bzip2 Filter the archive through bzip2. -J –xz Filter the archive through xz. -z –gzip Filter the archive through gzip.
For example, tar command examples, compress a directory.
Creating an archive of a directory as command below
[huupv@huupv devopsroles]$ tar -cvf folder.tar folder
The archiving a folder compressed “gzip” you can use -z option.
[huupv@huupv devopsroles]$ tar -czf folder.tar.gz folder
You can compress the archive with “bzip2” by using -j option
[huupv@huupv devopsroles]$ tar -cjf folder.tar.bz2 folder
Or compress “xz” by using the -J option.
[huupv@huupv devopsroles]$ tar -cJf folder.tar.xz folder
For example, Extract a directory from an archive
To extract a directory from an archive in the current location
[huupv@huupv devopsroles]$ tar -xvf folder.tar
Or to extract a directory from an archive to a specific “your_folder”.
[huupv@huupv devopsroles]$ tar -xvf folder.tar -C ./directory/your_folder
For example list archive content
Listing content as command below
[huupv@huupv devopsroles]$ tar -tvf folder.tar
For listing the content of a tar.gz archive
[huupv@huupv devopsroles]$ tar -tzvf folder.tar.gz
You can exclude one or several folders “–exclude” option as the command below
[huupv@huupv devopsroles]$ tar --exclude='./tar-folder/folder1'--exclude='./tar-folder/folder3' -cvf my-archive.tar ./tar-folder
The screen output terminal
./tar-folder/
./tar-folder/folder2/
Conclusion
Through the article, you can use tar command examples in Linux as above. These are just a few examples of how to use the tar command in Linux. The tar command offers many other options and functionalities, so you can refer to the command’s manual (man tar) for more detailed information and usage examples. I hope will this your helpful. Thank you for reading the DevopsRoles page!
Through the article, you can use Linux system information and hardware Information as above. These are just a few examples of commands you can use to obtain system and hardware information on Linux. Depending on your distribution and installed packages, there may be additional tools available. I hope will this your helpful. Thank you for reading the DevopsRoles page!
In this tutorial, How do I check disk space on Linux distribution? Sometimes you find out which directory consumes how much disk space. I used the du command and the df command. Linux the essential for DevOps Roles.
To check the disk space on a Linux system, you can use the df command. Here’s how you can do it:
Investigate the folder for Disk Usage
Checking Disk Space
Linux check disk space
Investigate the folder for Disk Usage
du command summarizes disk usage and recursively for files and directories
The syntax,
du [option]
For example, Summarizing disk usage in the current directory
[huupv@huupv devopsroles]$ du -sh *
The summarizing includes hidden files
[huupv@huupv devopsroles]$ du -sh .[!.]* *
you can add total the output by adding the -c option
[huupv@huupv devopsroles]$ du -csh .[!.]* *
The screen output terminal:
Investigate root director will only show folders with more than 20GB for disk usage
[huupv@huupv devopsroles]$ sudo du --threshold=20G -ch /.[!.]* /*
Checking Disk Space
[huupv@huupv devopsroles]$ df -h
Conclusion
Thought the article, you can use Linux check disk space as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!