Linux Shell Commands17 Mar 2025 | 2 min read In Linux, commands are ways or instructions through which you can instruct your system to do some action. Commands are executed in the command line. Syntax: There are some commands which don't have any option or don't accept any argument such as 'clear' and 'pwd'. clear The 'clear' command clears out all the previous commands and outputs from terminal display. pwd The 'pwd' command stands for 'print working directory'. It doesn't accept any option or argument and displays the detail of current working directory. Types of CommandsExternal or built-in commands Built-in commands are internal commands that are built-in the shell. Built-in commands are called from the shell and executed directly within the shell itself. You can list all built-in commands with the help of 'help' and 'compgen -b' command. Some example of built-in commands are 'pwd', 'help', 'type', 'set', 'unset', etc. External commands are other than built-in commands. These commands are programs which have their own binary and located in the filesystem. These are the commands that your system offer and are totally shell independent. Mostly these commands reside in /bin, /sbin, /usr/sbin. type commandLinux 'type' command tell us whether a command given to the shell is a built-in or external command. Syntax: Example: ![]() Look at above snapshot, commands like 'pwd' and 'cd' are built-in commands while commands 'man', 'cat', and 'file' are external commands. Linux 'type' command also tells whether a command is aliased or not. Example: ![]() Look at the above snapshot, 'type' command shows that 'ls' is an aliased command. type -aThe 'type -a' option tells about all type of command whether it is built-in, external, or aliased. Some commands are both external and built-in commands. But built-in command will always takes priority until and unless path of external command is mentioned. Syntax: Example: ![]() Look at the above snapshot, 'echo' command is internal as well as external. To use external 'echo' command, path "/bin/echo" is mentioned. whichLinux 'which' command locates the path of a command. Syntax: Example: ![]() Look at the above snapshot, except 'cd' command, all other commands are external commands because bash has displayed their external path. Next TopicLinux Aliases |
An argument, also called command line argument, can be defined as input given to a command line to process that input with the help of given command. Argument can be in the form of a file or directory. Arguments are entered in the terminal or console after...
2 min read
Shell History Commands While interacting with terminal, you'll be typing some commands very often and sometimes typing with variations on those commands. Sometimes it can be very irrritating as well as a little bit time consuming. Luckily, shell provides some commands to repeat the history of the commands...
1 min read
Pound Sign (#) Anything written after # sign will be ignored or will be considered as comment which will not be a part of the command execution. It is used as the comment sign. Comment means you can write anything for your view or benefit and it...
1 min read
Linux !! This command is also pronounced as 'bang bang' command. It repeats the last typed command in your shell. Syntax: !! Look t the above snapshot, 'ls' command is repeated by passing '!!' command. After that, 'echo command will be repeated' has also repeated. ! This command is pronounced as one...
1 min read
Displaying Shell Expansion When a command is entered in the command line, it expands into its output which is displayed. This is called expansion. The command you're typing will be printed with the help of echo command on the terminal. This command will be useful when you want to...
1 min read
Linux Dollar Question Mark ($?) This control operator is used to check the status of last executed command. If status shows '0' then command was successfully executed and if shows '1' then command was a failure. The exit code of the ious command is stored in the...
1 min read
Double Vertical Bar (||) The command shell interprets the (||) as the logical OR. This is opposite of logical AND. Means second command will execute only when first command will be a failure. Example: rm exm || file jtp.txt ; echo yes Look at the above snapshot, by listing the...
1 min read
Escaping Special Characters (\) Escaping characters are used to enable the use of control characters in the shell expansion but without interpreting it by the shell. Example: echo this \ \ \ \is \ \ \ \javatpoint. Look at the above snapshot, we have shown the use of some...
1 min read
Combining && and || The combination of logical AND and logical OR is used to write an if then else structure in the command line. If first condition (if) will be fulfilled then command line execution stops there. But if first condition is a failure, then second one (else)...
1 min read
Linux Double Ampersand (&&) The command shell interprets the && as the logical AND. When using this command, the second command will be executed only when the first one has been succcefully executed. Example: cd Desktop && cat jtp.txt Look at the above snapshot, both the commands are successfully executed. Let's...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India