Simple Approach To Red Hat Linux Commands

On my previous article we discussed in detail on how to configure and Install RedHat/CentOS 7 Linux. I always suggest you try to install CentOS core because Red Hat Linux is mainly used for server platform.
So, if you use CentOS Desktop, your server will be bulky as well as server overhead will increase. It may in most cases slow down your server performance. On the other hand, Linux always like to play with command rather than Graphical User Interface (GUI).

If you boot your CentOS 7 core system, you will find a command prompt which will ask you to login to your Linux system. In this command prompt, you can write any command to operate your Linux system. The last line of this command prompt contains four messages.
 [root@localhost ~] # root

Here root is the user who have logged in to the system. If you login with another username, it will change according to your user name.

localhost: Hostname of your system.
If you have not changed while installing operating system, it will be localhost by default. It can be changed later by using command.

Location (~): User’s current location will be shown here. As I have logged in as a root user, it is showing (~) means /root cd command is mainly used to change the current location.

 User type (# or $):

For normal user it will be ($) and for the root user it will be (#). User Type in Red Hat Linux There are three types of user in Red Hat Linux system.

System user
System users are those users who cannot login the system but necessary for running various service such mail, ftp, apache etc

Root use
r: root user is the administrator or super user of Red Hat Linux system. Root user can do any task in Red Hat Linux.
Regular user

Regular user can login to the system and can do some tasks with limitation but cannot do administrative task. Root user can assign administrative task to any regular user if he wants.
A command run from the command prompt will generally have below structure.

Command -option or argument In Red Hat Linux system, both –option and are optional. A command can perform its task without option and filename or it can take either -option or filename to perform its task.
For example, if you want to show available directories and files in your current location, you can type ls command which will show files and directories in short format.
But if you want to show in long format, you can type ls -l which will show files and directories in long format.
Again if wish to show files and directories in long format within a specific directory, you can type ls –l such as /var/log which will show all the files and directories within the specific directory with long format.

Here are the most Essential and Frequently Used Commands in Red Hat Linux.

CMD 1: man

The man command is used to show the manual page of any Red Hat Linux built-in command. It is one of the most useful commands to any Linux system administrator because it helps to find available options and usage of any command with example so easily.

For example, if you want to know details about cd command, just use man command like below. [root@localhost ~] # man cd You will find detail manual page of cd command now. Press UP and Down arrow key to scroll this manual page or type ’q’ to quit this manual page.

 CMD 2help The help command is another useful command which returns quick summery of any built-in command. For example, if you want to know usage of cd command quickly, use this help command like below. [root@localhost ~] # help cd The help command will now show you a quick summary of cd command.

CMD 3: pwd The pwd command prints the full file name of the current working directory. If you need to know your present working directory, just use pwd command like below. [root@localhost ~] # pwd Now you will be able to show your current working directory as output. For more details about this command, please use man pwd command.

CMD 4: cd The cd command is used to switch directory path. It takes directory path as its argument. For example, if you want to go /var/log directory, just use cd command like below. [root@localhost ~] # cd /var/log Now your current directory or working directory will be log directory. To know more about cd command, please use man cd command in your shell prompt. In Red Hat Linux system, there are two ways to define directory path. Absolute path: If directory path starts with root directory (/), it is called absolute path. For example, /var/log/maillog this directory path starts with root directory, so this path notation will be called absolute path. Relative path: If path notation does not start with root directory, it is defined as relative path. Say your current directory is root directory and you want to go log directory. In this case, you can use cd command like below. [root@localhost /] # cd var/log Here relative path notation is used because directory path does not start with root directory.

 CMD 5

ls The ls command shows all the contents in a directory. According to the content color, you can identify the type of any content.

A list of content color is given below. Content Type Color Directory Blue File Black and White Compress File (zip/rar/rpm) Red Executable File Green Device (terminal/cd/dvd/usb/hdd) Yellow Picture/image/media Magenta Link File Cyan A lot of options are available for ls command. Say, if you want to see long listing file format, you can use ls –l command. To know more about ls command options, please use man ls command. You will find details about ls command there.

 CMD 6

mkdir The mkdir command is to create a directory in any location in your system. Say, you want to create a directory/folder named class in your current directory. Then use mkdir commend like below. [root@localhost ~] # mkdir class So, you will find a folder named class has been created in your current directory. Use man command to know more about mkdir command.

 CMD 7touch

The touch command is used to create a file your desired directory. Say, you want to create a text file named lecture1 in your current directory. Then use touch command like below.
[root@localhost ~] # touch lecture1 So, you will find a file named lecture1 has been created in your current directory. You will find more details about touch command using man command.

 CMD 8: cp 

The cp command is used to copy any file or directory. Format of cp command is given below. cp [–option] source file name and path destination file name and path [–option] is optional. Say, if you want to copy your lecture1 file in /var directory with another name, use cp command like below.

 [root@localhost ~] # cp lecture1 /var lecture1.bak So, you will get a copy of lecture1 file in /var directory and its name will be lecture1.bak. For more details about cp command, please use man command.

CMD 9: rm
 The rm command is used to remove any file or directory. It takes file or directory name with path as its argument. Say, you want to delete the lecture1.bak file that you have copied in /var directory with cp command. Then use rm command like below. [root@localhost ~] # rm -f /var/lecture1.bak Your lecture1.bak file will be removed as soon as you execute this command. Here –f is an option which stands for force. If you don’t use this option, you will be asked to confirm for file or directory removal. A lot of options are also available for rm command. Please run man rm command to get details.

CMD 10: vi Like windows notepad, vi is a text editor. Any kind of plain text can be edit with vi shell editor. Say, you want to write some text in your lecture file. Then open lecture file with vi editor like below.

 [root@localhost ~] # vi lecture By default vi editor will be opened as read mode. Now press ‘i’ to enable write mode and write your text that you want to write. Press ‘Esc’ key to go back in read mode. Generally :q keys are used to quit any opened file. But as you have edited this file, you have to save this file. So, use :wq keys to save and quit this file. If you want not to save this file but quit, use :q! keys combination.

 CMD 11:

shutdown The shutdown command is used to halt, power-off or reboot your Linux system. Say, you want to down your system immediately, use shutdown command like below.
[root@localhost ~] # shutdown now Now your system will go power-off state. If you want to reboot your system, you can use shutdown command with an extra option like below.
[root@localhost ~] # shutdown –r now So, your system will reboot now. A lot of arguments and options are also available for shutdown command. Please see man shutdown command for more details.
here is the much we can take on Simple Approach To Red Hat Linux Commands, but if have any challenge doing any of the above please leave a comment in comment box below.

Leave a Reply

Your email address will not be published. Required fields are marked *