We have a 3 different types of commands………………
1. Internal commands :- An internal command is a built-in command into the shell. The shell does not start a separate process to run internal commands. Ex- "cd" command
2. Aliases :- An alias is a user defined command as per need. Type alias on the command line to see the provided default aliases. Ex- alias newcommand=’oldcommand’,
alias ll=’ls -l – color=auto' Aliases are executed before anything else.
3. External commands :- When we type the name of a command, the shell first checks if it is a built-in command,executes it. If we write a command with its pathname beginning with like /,/usr/bin then shell does not search the command. It executes it with its path. If the command is not built-in or not specified absolute path then shell looks in its search path for an executable program or script with the given name.The search path is a list of directories that the shell look through for a command whose name matches with the command. External commands require the shell to fork and exec a new subprocess, this takes time. That’s why external commands are slow.
[root@TEST /]# type cd //To check the type of command.//
$PATH variable is used to share or define the path of external commands. To find out command location use which.Ex:- Type “which ls” To run a command from the current directory you have to include ./ in front of command. The dot stands for the current directory, and by running it as ./ you’ll tell bash to look for the command in the current directory.
STANDARD COMMANDS LINE TOOLS
1. Tilde (~) :- Shows that user is in home directory.
[root@TEST~]#
2. pwd :- Print working directory
[root@TEST ~]# pwd
/root
3. cd :- Change Directory
[root@TEST ~]# cd /opt
[root@TEST opt]#
4. To see the available files or directories in present directory or a specifid location
[root@TEST opt]# ls // Shows in list form.//
[root@TEST opt]# ls -a // list in alphabetic order.//
[root@TEST opt]# ll // list with detailed information.//
[root@TEST opt]# ll -t // list in time ascending order.//
5.
[root@TEST opt]# touch file1 // Create a empty file name “file1”//
[root@TEST opt]# cat file1 // Display the file data in read format.//
[root@TEST opt]# mkdir dir1 // Create a directory in present directory.//
[root@TEST opt]# mkdir -p dir1/dir2/dir3 // Create multiple directory in one time.//
[root@TEST opt]# mkdir /opt/dir1 // Create directory in /opt //
6. VI Editor:- We use it to edit files at command line.
[root@TEST opt]# vi file1 // Its open the file in coomand line//
Press “i”:- To insert data or write in file.
Press “Esc + / + word”:- To search a word location in file.
Press “Esc + : + wq” :- To write and exit from file.
Press “Esc + : + set number” :- To show the line number in vi editor.
7.
[root@TEST opt]# rm file1 // To delete a file.//
[root@TEST opt]# rm -f file1 // Delete file without ask you. F= forecefully//
[root@TEST opt]# rm -rf // Delete directory within directory forcefully.//
8.
[root@TEST opt]# find file OR dir-name // Search in present working directory. //
[root@TEST opt]# find /opt file/dir-name // Search in specified /opt directory for file/dir. //
[root@TEST opt]# locate file/dir-name // Show you the exact path of file/dir. //
The above locate command uses a database to search the files or directory. This database get updated once a day. To update the database of locate command type
[root@TEST ~]# /etc/cron.daily/mlocate OR
[root@TEST ~]# updatedb -v //v will show you files.//
9. head/tail :- Bydefault shows 10 top/last lines of file. You can change the number of line to display.
[root@TEST ~]# head -n15 /etc/yum.repos.d/CentOS- Base.repo // Show 15 top lines //
[root@TESt ~]# tail -n15 /etc/yum.repos.d/CentOS-Base.repo // Show 15 last lines //
[root@TEST~]# less /etc/yum.repos.d/CentOS-Base.repo
//move up/down with page up/down key. less can open .gz file without mount it. //
[root@TEST ~]# more /etc/yum.repos.d/CentOS-Base.repo
//Scroll from top to down one page per screen. //
Grep command is used to fetch specific data from file or input. Ex:-
[root@TEST opt]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
[root@TEST opt]# ps -A | grep chrome
4389 ? 01:25:02 chrome
4429 ? 00:00:00 chrome-sandbox
4430 ? 00:00:00 chrome
4439 ? 00:00:00 chrome-sandbox
4442 ? 00:00:01 chrome
4575 ? 01:03:08 chrome
In the above command ps shows the information about the active processes. Option -A shows the all running processes. “grep chrome” shows the running processes of chrome.
[root@TEST opt]# ps -u username // shows the processes runnning under username.//
To kill a process use process id or kill all processes running by that application use:
[root@TEST opt]# kill pid-no //pid-no shows by ps -option command in 1st column.//
[root@TEST opt]# pkill process-name // kill all processes running by process-name.//
No comments:
Post a Comment