Let’s talk about: Most used shell commands

The most widely used shell on Linux is Bourne Again Shell or Bash. Most linux distribution ships with BASH pre-installed. An alternative to Bash, a very popular shell is Z-Shell or ZSH.

The Bourne shell command syntax is a superset of Bash command syntax. Since bash 2.05a, among other things, it enables brace expansion, command line completion, basic debugging, and signal handling (using trap). With the exception of Bourne shell scripts falling into fringe syntax behavior handled differently in Bash or attempting to run a system command matching a newer Bash builtin, Bash can execute the vast majority of Bourne shell scripts without modification. Command line editing, command history (history command), the directory stack, the $RANDOM and $PPID variables, and POSIX command substitution syntax are all ideas borrowed from the KornShell (ksh) and the C shell (csh).

Dollar sign is the default symbol for regular users:

$ <command>

and number sign or hash tag for the root user:

# <command>

Take note:

The dollar ($) and pound (#) symbols indicate a prompt in the following examples.

A **`$`** implies that the command is open to all users, whereas a **`#`** suggests that you are the only one who may perform it.
should execute the command as root; many administrative tools require root access.
authorisation to run them is required. The command you type is followed by the prompt.
(After that, press Enter). The output of the command is shown in the lines that follow.

Terminal window πŸͺŸ

When you open your terminal, you’ll see something similar to this. A blinking line cursor next to the prompt will appear where you can type text or commands.

[sean@linux]$

Running commands:

The date command is our first command, and it displays the current date. The date command, when run without any arguments or options, displays the current full date and time.

[sean@linux]$ date
Sat Jun 18 08:02:44 PM PST 2022

Other commands:

The ls command lists the files and directories in your current directory.

[sean@linux]$ ls
Home Downloads Github Pictures
Documents Public Templates Videos

pwd command prints the current working directory.

[sean@linux]$ pwd
/home/sterben/

echo command prints or displays a line of text, depending on the arguments that you passed in. Mostly used in shell scripts to output the status to the screen or on a file.

[sean@linux]$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:↡
/home/sterben/bin

history is used to review your shell’s command history. You can include a number as an argument to set a limitation of how many recent commands to print.

[sean@linux]$ history 5
ls
pwd
cd Downloads
cd ..
sudo pacman -Syu

cd is used to move from the current directory into the target directory, running it without a directory as an argument, moves to the root directory.

[sean@linux]$ cd /home/sterben/Downloads

and running pwd after changing directory would result to,

[sean@linux]$ pwd
/home/sterben/Downloads

rm is used to remove/delete files, also running it with argument -rf removes directories and files inside it. -r flag stands for recursive and -f means forced.

[sterben@linux]$ rm <target-file>

or with -rf arguments

[sterben@linux]$ rm -rf <target-file or directory>

To sum things up πŸ“š

What we covered today are the most commonly used commands in linux shell. I highly recommend reading linux books if you are a beginner. There are tech videos on youtube that will help you on your learning journey. Don’t hesitate to reach out, if you want to request for a certain topic.


#linux #bash #zsh