Mastering Linux Commands and Productivity Tips on RHEL 9
Ddhruv Arora
Engineering Student | MERN Stack and Flutter Developer | DevOps Enthusiast | Python Programmer | President RAIoT Labs
Introduction
Linux is a powerful operating system known for its versatility and robustness. If you're running Red Hat Enterprise Linux 9 on a virtual machine, you have access to a wealth of commands and tools to enhance your productivity. In this blog, we'll explore a wide range of commands, shortcuts, and productivity tips that will help you make the most of your Linux experience on the RHEL 9 graphical user interface (GUI).
1. Working with Dates and Calendars
Linux makes it easy to work with dates and calendars. You can use the date command to display the current date and time. Additionally, you can use the cal command to generate a calendar for a specific month and year.
2. Browsing the Web with Firefox
Need to access the internet? Simply launch the Firefox web browser from the GUI, use firefox&
3. Managing Processes
- Ctrl + C: Stop a running process.
- Ctrl + Z: Pause a program and move it to the background.
- fg: Bring a paused program back to the foreground.
- command &: Run a command in the background while keeping it in a running state.
4. Text Editing with Gedit
Gedit is a user-friendly GUI-based text editor for creating and editing files.
use the command gedit to start it.
5. Running Commands Independently with Nohup
Use the nohup command to run Linux commands independently, ensuring that closing the terminal won't terminate the program.
Example: nohup firefox
6. Terminal Shortcuts
- Ctrl + S: Hide input in the terminal.
- Ctrl + Q: Show hidden input.
- Ctrl + L: Clear the terminal screen.
- Ctrl + U: Remove the entire command line.
7. Taking Screenshots
Capture your screen or specific windows using the gnome-screenshot command, and customize it with options like -f and -d, alternatively, you can use the print-screen key as well.
8. File Management
- ls and dir: Listing files and directories.
- cd: Change the current directory.
9. Viewing Images
Open images in the default image viewer with the eog command.
10. Creating and Editing Files with Vim
Create, edit, and secure text files with the Vim text editor.
- Create a file using vim <file_name>
- Use ‘i’ to insert text in the file
-?Use ‘:wq’ to save and quit
-?Use vim +X <file_name> to make it password protected
11. Automate Tasks with Cron
Use crontab to schedule tasks at specified times.
The format for scheduling is: min hour date month dayofweek command.
The command used crontab -e will open the cron job file.
12. Finding the Right Command
Use apropos to find commands based on keywords, making it easier to discover the right command for your task.
13. Accessing Manual Pages
Access comprehensive manual pages for commands using the man command, press q to quit.
14. Command History
Review your command history using the history command.
16. Reading Files with cat
Display the contents of a file using the cat command.
17. Fun with Cowsay
Add a touch of humor to your terminal with the cowsay command.
To install use: yum install -y cowsay, then use the following command
cowsay Hello hi
18. Configuring Package Management with Yum
Set up Yum for package installation and management.
firstly navigate to /etc/yum.repos.d/
cd /etc/yum.repos.d/
create a file named "yumlocal.repo"
vim yumlocal.repo
Add the following lines:
The yum in now configured, make sure that OS Dvd is mounted.
19. Installing the "fuck" Environment
Enhance your command-line experience with the "fuck" tool, making it easy to correct mistyped commands.
firstly install it using pip3 as shown,
pip3 install thefuck
then, start the fuck env, type in fuck twice on cmd to start it.
now, just use thefuck before any command and it will be ready to help you
Example usage:
20. Keyboard Bindings
Explore and manage keyboard bindings with the bind -p command.
21. File Transfer with Rsync
Consider using rsync as an alternative to the SCP command for efficient file transfers, also it provides tons of options like key logging, tracking, etc.
22. Identifying the Current User
Use whoami to display information about the current user.
23. User Management
- To add a new user we can use “useradd <user_name>” and to set the password use "passwd <user_name>" command
- To lock a user from root account use passwd -l <user_name>
-?To unlock the user use passwd -u <user_name>
-??chpasswd ?to update multiple passwords together, use the notation user_name:password and to exit use ctrl + D
jack:redhat?????
Example:
24. Working with Text-to-Speech
Utilize the espeak-ng command for speech synthesis.
Example usage, to get current date as output:
date | espeak-ng
25. Combining Commands with Pipes
Combine multiple commands using the pipe (`|`) operator to create powerful data processing pipelines.
Example, finding specific file with combination of ls and grep:
ls | grep test.txt
Output:
26. System Information with "last"
Access detailed system login information using the last command.
Example:
27. Networking and IP Address
Retrieve IP address information with the ifconfig command and discover your public IP address with curl ifconfig.me
Get private IP address using:
ifconfig
The expected output:
Get the public IP address info:
curl ifconfig.me
The expected output:
28. Creating ASCII Art
Transform text into eye-catching ASCII art with the figlet command.
Example:
figlet hi
Output:
29. Monitoring with "watch"
Automate the execution of commands at specified intervals using the watch command.
Example: Creating a real-time digital watch, use the following command:
watch -t -n1 "date +%T | figlet"
Output:
30. Tracking User Activity
Check user logins and usage using the who and ac commands.
- To see the user accounting day we can use “ac -d”
- To see the user-wise accounting we can use “ac -p”
- We can also combine them “ac -d -p”
31. Enhancing Authentication Security
Use authconfig to manage user authentication and faillock settings.
Firstly install it using:
yum install authconfig
- To lock the user on failed password attempts and unlock them after 24hrs or so we can use the following command:
authconfig –enablefaillock –faillockargs=”deny=3 unlock_time=60” –update
- to check for failed attempts use: faillock on root account
- to manually unlock the locked account, use
faillock --user <user_name> --reset
32. Process Management
Monitor and manage running processes with the ps command and sort them with various options.
Example:
ps -aux
Output:
33. Searching Text with "grep"
Find text patterns in files and directories using the versatile grep command.
Example: Finding the IPv4 and IPv6
34. Disk Usage Information
Check disk space usage with the df command and also get other valuable insights.
35. Finding Large Files
Locate large files with the find command.
The command:
find -type f -size 100M
So, on my system, there is no file larger than 100Mb, so I reduced it to 10Mb for the demo, and here is the output:
36. Explore Telehack
Discover Telehack for an online Linux terminal experience.
Conclusion
Mastering these Linux commands and productivity tips will greatly enhance your experience when running Red Hat Enterprise Linux 9 with a graphical user interface. Whether you're a beginner or an experienced Linux user, these tools and shortcuts can streamline your workflow, boost productivity, and make your Linux journey more enjoyable and efficient.
Thank you for reading this article, hope you liked it!
Silicon CAD Engineer CW@Meta Inc. | Linux | Python | Machine Learning | Artificial Intelligence | Perl | Make | TCL | JAVA | BASH
1 个月Thank you
R&I Engineer || 2x RedHat Certified || Logic App || Function App || Azure DevOps || Full Stack Developer || Cloud Computing || Containerization || Kubernetes || Data Science || Shell Scripting
1 年Great work