🐧What is Linux?

Linux is a community of open-source Unix-like operating systems that are based on the Linux Kernel. It was initially released by Linus Torvalds on September 17, 1991.

Just like Windows, iOS, and Mac OS, Linux is an operating system. In fact, one of the most popular platforms on the planet, Android, is powered by the Linux operating system. An operating system is software that manages all of the hardware resources associated with your desktop or laptop. To put it simply, the operating system manages the communication between your software and your hardware.

Open source -

Linux is also distributed under an open-source license. Open source follows these key tenets:

  • The freedom to run the program, for any purpose.

  • The freedom to study how the program works, and change it to make it do what you wish.

  • The freedom to redistribute copies so you can help your neighbor.

  • The freedom to distribute copies of your modified versions to others.

These points are crucial to understanding the community that works together to create the Linux platform. Without a doubt, Linux is an operating system that is “by the people, for the people”. These tenets are also a main factor in why many people choose Linux. It’s about freedom and freedom of use and freedom of choice.

Linux Architecture -

The Linux operating system's architecture mainly contains some of the components: the Kernel, System Library, Hardware layer, System, and Shell utility.

1. Kernel:- The kernel is one of the core section of an operating system. It is responsible for each of the major actions of the Linux OS. This operating system contains distinct types of modules and cooperates with underlying hardware directly. The kernel facilitates required abstraction for hiding details of low-level hardware or application programs to the system. There are some of the important kernel types which are mentioned below:

  • Monolithic Kernel

  • Micro kernels

  • Exo kernels

  • Hybrid kernels

2. System Libraries:- These libraries can be specified as some special functions. These are applied for implementing the operating system's functionality and don't need code access rights of the modules of kernel.

3. System Utility Programs:- It is responsible for doing specialized level and individual activities.

4. Hardware layer:- Linux operating system contains a hardware layer that consists of several peripheral devices like CPU, HDD, and RAM.

5. Shell:- It is an interface among the kernel and user. It can afford the services of kernel. It can take commands through the user and runs the functions of the kernel. The shell is available in distinct types of OSes. These operating systems are categorized into two different types, which are the graphical shells and command-line shells.

The graphical line shells facilitate the graphical user interface, while the command line shells facilitate the command line interface. Thus, both of these shells implement operations. However, the graphical user interface shells work slower as compared to the command-line interface shells.

There are a few types of these shells which are categorized as follows:

  • Korn shell

  • Bourne shell

  • C shell

  • POSIX shell

Linux Operating System Features -

  • Portable: Linux OS can perform different types of hardware and the kernel of Linux supports the installation of any type of hardware environment.

  • Open source: Linux operating system source code is available freely and for enhancing the capability of the Linux OS, several teams are performing in collaboration.

  • Multiprogramming: Linux OS can be defined as a multiprogramming system. It means more than one application can be executed at the same time.

  • Multi-user: Linux OS can also be defined as a multi-user system. It means more than one user can use the resources of the system such as application programs, memory, or RAM at the same time.

  • Hierarchical file system: Linux OS affords a typical file structure where user files or system files are arranged.

  • Security: Linux OS facilitates user security systems with the help of various features of authentication such as controlled access to specific files, password protection, or data encryption.

  • Shell: Linux operating system facilitates a unique interpreter program. This type of program can be applied for executing commands of the operating system. It can be applied to perform various types of tasks such as call application programs and others.

Linux Distribution

Linux distribution is an operating system that is made up of a collection of software based on the Linux kernel or you can say distribution contains the Linux kernel and supporting libraries and software. And you can get Linux based operating system by downloading one of the Linux distributions and these distributions are available for different types of devices like embedded devices, personal computers, etc. Around 600 + Linux Distributions are available and some of the popular Linux distributions are: MX Linux

  • Manjaro

  • Linux Mint

  • elementary

  • Ubuntu

  • Debian

  • Solus

  • Fedora

  • openSUSE

  • Deepin

Basic Task -

  1. Check your present working directory.

  2. List all the files or directories including hidden files.

  3. Create a nested directory A/B/C/D/E

    What is the Current Working Directory

    The current working directory is the directory in which the user is currently working. Each time you interact with your command prompt, you are working within a directory.

    By default, when you log into your Linux system, your current working directory is set to your home directory. To change the working directory use the cd command.

    For example, to change the current working directory to /tmp you would type: $ cd /tmp

    PWD command -

    pwd Command The pwd command stands for print working directory. It is one of the most basic and frequently used commands in Linux. When invoked the command prints the complete path of the current working directory.

    $ type -a pwd

    output - pwd is a shell builtin pwd is /bin/pwd

    As you can see from the output below, the shell builtin has priority over the standalone executable and it is used whenever you type pwd. If you want to use the standalone pwd binary type the full path to the file /bin/pwd

    How to Find your Current Working Directory #

    To find out what directory you are currently in, type pwd in your terminal: $ pwd

    The output will look something like this:

    /home/ubuntu

    The pwd command can accept only two arguments:

    -L (--logical) - Do not resolve symlinks. -P (--physical) - Display the physical directory, without any symbolic links.

    By default, id no option is used, pwd behaves as if -L option is specified.

    List all the files or directories including hidden files.

    The ls is the list command in Linux. It will show the full list or content of your directory. Just type ls and press the enter key. The whole content will be shown.

    ls is a command used to list computer directories and files in Unix-like and Unix operating systems. It is developed by the Single Unix Specification and POSIX. It's available inside the EFI shell, as a component of the UnxUtils group of native Win32 ports of basic GNU Unix-like utilities as an isolated package for Microsoft Windows, or as a component of the MSX-DOS2 Tools of ASCII for MSX-DOS version 2.

    ls --> The ls command is used to list files or directories in Linux and other Unix-based operating systems.

    ls -l--> Type the ls -l command to list the contents of the directory in a table format with columns including.

    ls *.sh --> List the files ext with .sh

    ls ip_* --> To list any files or directories that have names starting with "ip_" use this format:

    ls -i --> List the files and directories with index numbers in orders

    ls -d */ --> Type the ls -d */ command to list only directories.

    Directory commands :

    • pwd --> Print work directory. Gives the present working directory.

    • cd path_to_directory --> Change the directory to the provided path.

    • cd ~ or just cd --> Change the directory to the home directory.

    • cd .. --> Change directory to one step back.

    • cd ../.. --> Use ls ../.. for contents two levels above.

    • mkdir directoryName --> Use to make a directory in a specific location

    • mkdir .NewFolder --> Make a hidden directory (also . before a file to make it hidden)

    • mkdir A B C D --> Make multiple directories at the same time.

    • mkdir /home/user/Mydirectory --> Make a new folder in a specific location

Create a nested directory A/B/C/D/E

mkdir -p A/B/C/D --> Make a nested directory

Man Command -

man command in Linux is used to display the user manual of any command that we can run on the terminal. It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.

Every manual is divided into the following sections:

  • Executable programs or shell commands

  • System calls (functions provided by the kernel)

  • Library calls (functions within program libraries

  • Games

  • Special files (usually found in /dev)

  • File formats and conventions eg /etc/passwd

  • Miscellaneous (including macro packages and conventions), e.g. groff(7)

  • System administration commands (usually only for root)

  • Kernel routines [Non-standard]

Syntax :

$man [OPTION]... [COMMAND NAME]..

1. No Option: It displays the whole manual of the command.

Syntax :

$ man [COMMAND NAME]

Example - $ man printf

Basic command -

sudo command **- It is a short name for "**superuser do"

sudo is one of the most common Linux commands that lets you perform tasks that require administrative or root permissions.

sudo is one of the most common Linux commands that lets you perform tasks that require administrative or root permissions.

You can also add an option, such as:

  • -k or –reset-timestamp invalidates the timestamp file.

  • -g or –group=group runs commands as a specified group name or ID.

  • -h or –host=host runs commands on the host.

cd command - Change directory

  • cd ~[username] goes to another user’s home directory.

  • cd .. moves one directory up.

  • cd- moves to your previous directory.

cat command - Concatenate, or cat

Concatenate, or cat, is one of the most frequently used Linux commands. It lists, combines, and writes file content to the standard output. To run the cat command, type cat followed by the file name and its extension. For instance:

cat filename.txt.

Here are other ways to use the cat command:

  • cat > filename.txt creates a new file.

  • cat filename1.txt filename2.txt > filename3.txt merges filename1.txt and filename2.txt and stores the output in filename3.txt.

  • tac filename.txt displays content in reverse order.

cp command - Use the cp command to copy files or directories and their content.

cp filename.txt /home/username/Documents

To copy files to a directory, enter the file names followed by the destination directory:

cp filename1.txt filename2.txt filename3.txt /home/username/Documents

To copy the content of a file to a new file in the same directory, enter cp followed by the source file and the destination file:

cp filename1.txt filename2.txt

To copy an entire directory, pass the -R flag before typing the source directory, followed by the destination directory:

cp -R /home/username/Documents /home/username/Documents_backup

mv command - move

The primary use of the mv command is to move and rename files and directories. Additionally, it doesn’t produce an output upon execution.

Simply type mv followed by the filename and the destination directory. For example, you want to move filename.txt to the /home/username/Documents directory:

mv filename.txt /home/username/Documents.

You can also use the mv command to rename a file:

mv old_filename.txt new_filename.txt

rmdir command - remove empty directory

To permanently delete an empty directory, use the rmdir command. Remember that the user running this command should have sudo privileges in the parent directory.

For example, you want to remove an empty subdirectory named personal1 and its main folder mydir:

rmdir -p mydir/personal1

rm command - remove

The rm command is used to delete files within a directory. Make sure that the user performing this command has write permissions.

Remember the directory’s location as this will remove the file(s) and you can’t undo it.

Here’s the general syntax:

rm filename

To remove multiple files, enter the following command:

rm filename1 filename2 filename3

Here are some acceptable options you can add:

  • -i prompts system confirmation before deleting a file.

  • -f allows the system to remove without a confirmation.

  • -r deletes files and directories recursively.

touch command - Create an empty file

The touch command allows you to create an empty file or generate and modify a timestamp in the Linux command line.

For example, enter the following command to create an HTML file named Web in the Documents directory:

touch /home/username/Documents/Web.html

find command -

Use the find command to search for files within a specific directory and perform subsequent operations. Here’s the general syntax:

find [option] [path] [expression]

For example, you want to look for a file called notes.txt within the home directory and its subfolders:

find /home -name notes.txt

Here are other variations when using find:

  • find -name filename.txt to find files in the current directory.

  • find ./ -type d -name directoryname to look for directories.

grep command -

Another basic Linux command on the list is grep or global regular expression print. It lets you find a word by searching through all the texts in a specific file.

Once the grep command finds a match, it prints all lines that contain the specific pattern. This command helps filter through large log files.

For example, you want to search for the word blue in the notepad.txt file:

grep blue notepad.txt

The command’s output will display lines that contain blue.

df command -

Use the df command to report the system’s disk space usage, shown in percentage and kilobyte (KB). Here’s the general syntax:

df [options] [file]

For example, enter the following command if you want to see the current directory’s system disk space usage in a human-readable format:

df -h

These are some acceptable options to use:

  • df -m displays information on the file system usage in MBs.

  • df -k displays file system usage in KBs.

  • df -T shows the file system type in a new column.

du command -

If you want to check how much space a file or a directory takes up, use the du command. You can run this command to identify which part of the system uses the storage excessively.

Remember, you must specify the directory path when using the du command. For example, to check /home/user/Documents enter:

du /home/user/Documents

Adding a flag to the du command will modify the operation, such as:

  • -s offers the total size of a specified folder.

  • -m provides folder and file information in MB

  • k displays information in KB.

  • -h informs the last modification date of the displayed folders and files.

head command -

The head command allows you to view the first ten lines of a text. Adding an option lets you change the number of lines shown. The head command is also used to output piped data to the CLI.

Here’s the general syntax:

head [option] [file]

For instance, you want to view the first ten lines of note.txt, located in the current directory:

head note.txt

Below are some options you can add:

  • -n or –lines prints the first customized number of lines. For example, enter head -n 5 filename.txt to show the first five lines of filename.txt.

  • -c or –bytes prints the first customized number of bytes of each file.

  • -q or –quiet will not print headers specifying the file name.

diff command -

Short for difference, the diff command compares two contents of a file line by line. After analyzing them, it will display the parts that do not match.

Programmers often use the diff command to alter a program instead of rewriting the entire source code.

Here’s the general format:

diff [option] file1 file2

For example, you want to compare two text files – note.txt and note_update.txt:

diff note.txt note_update.txt

Here are some acceptable options to add:

  • -c displays the difference between two files in a context form.

  • -u displays the output without redundant information.

  • -i makes the diff command case insensitive.

history command -

With history, the system will list up to 500 previously executed commands, allowing you to reuse them without re-entering. Keep in mind that only users with sudo privileges can execute this command. How this utility runs also depends on which Linux shell you use.

To run it, enter the command below:

history [option]

This command supports many options, such as:

  • -c clears the complete history list.

  • -d offset deletes the history entry at the OFFSET position.

  • -a appends history lines.

man command -

The man command provides a user manual of any commands or utilities you can run in the Terminal, including the name, description, and options.

It consists of nine sections:

  • Executable programs or shell commands

  • System calls

  • Library calls

  • Games

  • Special files

  • File formats and conventions

  • System administration commands

  • Kernel routines

  • Miscellaneous

To display the complete manual, enter:

man [command_name]

For example, you want to access the manual for the ls command:

man ls

Enter this command if you want to specify the displayed section:

man [option] [section_number] [command_name]

For instance, you want to see section 2 of the ls command manual:

man

Essential Linux Commands That Every User Should Know -

sudo command -

Short for superuser do**,** sudo is one of the most common Linux commands that lets you perform tasks that require administrative or root permissions.

When using sudo, the system will prompt users to authenticate themselves with a password. Then, the Linux system will log a timestamp as a tracker. By default, every root user can run sudo commands for 15 minutes/session.

If you try to run sudo in the Linux command line without authenticating yourself, the system will log the activity as a security event.

Here’s the general syntax:

sudo (command)

You can also add an option, such as:

  • -k or –reset-timestamp invalidates the timestamp file.

  • -g or –group=group runs commands as a specified group name or ID.

  • -h or –host=host runs commands on the host.

pwd command -

Use the pwd command to find the path of your current working directory. Simply entering pwd will return the full current path – a path of all the directories that starts with a forward slash (/). For example, /home/username.

The pwd command uses the following syntax:

pwd [option]

It has two acceptable options:

  • -L or –logical prints environment variable content, including symbolic links.

  • -P or –physical prints the actual path of the current directory.

cd command -

To navigate through the Linux files and directories, use the cd command. Depending on your current working directory, it requires either the full path or the directory name.

Running this command without an option will take you to the home folder. Keep in mind that only users with sudo privileges can execute it.

Let’s say you’re in /home/username/Documents and want to go to Photos, a subdirectory of Documents. To do so, enter the following command:

cd Photos.

If you want to switch to a completely new directory, for example, /home/username/Movies, you have to enter cd followed by the directory’s absolute path:

cd /home/username/Movies

Here are some shortcuts to help you navigate:

  • cd ~[username] goes to another user’s home directory.

  • cd .. moves one directory up.

  • cd- moves to your previous directory.

ls command -

The ls command lists files and directories within a system. Running it without a flag or parameter will show the current working directory’s content.

To see other directories’ content, type ls followed by the desired path. For example, to view files in the Documents folder, enter:

ls /home/username/Documents

Here are some options you can use with the ls command:

  • ls -R lists all the files in the subdirectories.

  • ls -a shows hidden files in addition to the visible ones.

  • ls -lh shows the file sizes in easily readable formats, such as MB, GB, and TB.

cat command -

Concatenate, or cat, is one of the most frequently used Linux commands. It lists, combines, and writes file content to the standard output. To run the cat command, type cat followed by the file name and its extension. For instance:

cat filename.txt.

Here are other ways to use the cat command:

  • cat > filename.txt creates a new file.

  • cat filename1.txt filename2.txt > filename3.txt merges filename1.txt and filename2.txt and stores the output in filename3.txt.

  • tac filename.txt displays content in reverse order.

cp command -

Use the cp command to copy files or directories and their content. Take a look at the following use cases.

To copy one file from the current directory to another, enter cp followed by the file name and the destination directory. For example:

cp filename.txt /home/username/Documents

To copy files to a directory, enter the file names followed by the destination directory:

cp filename1.txt filename2.txt filename3.txt /home/username/Documents

To copy the content of a file to a new file in the same directory, enter cp followed by the source file and the destination file:

cp filename1.txt filename2.txt

To copy an entire directory, pass the -R flag before typing the source directory, followed by the destination directory:

cp -R /home/username/Documents /home/username/Documents_backup

mv command -

The primary use of the mv command is to move and rename files and directories. Additionally, it doesn’t produce an output upon execution.

Simply type mv followed by the filename and the destination directory. For example, you want to move filename.txt to the /home/username/Documents directory:

mv filename.txt /home/username/Documents.

You can also use the mv command to rename a file:

mv old_filename.txt new_filename.txt

mkdir command -

Use the mkdir command to create one or multiple directories at once and set permissions for each of them. The user executing this command must have the privilege to make a new folder in the parent directory, or they may receive a permission denied error.

Here’s the basic syntax:

mkdir [option] directory_name

For example, you want to create a directory called Music:

mkdir Music

To make a new directory called Songs inside Music, use this command:

mkdir Music/Songs

The mkdir command accepts many options, such as:

  • -p or –parents create a directory between two existing folders. For example, mkdir -p Music/2020/Songs will make the new “2020” directory.

  • -m sets the file permissions. For instance, to create a directory with full read, write, and execute permissions for all users, enter mkdir -m777 directory_name.

  • -v prints a message for each created directory.

rmdir command -

To permanently delete an empty directory, use the rmdir command. Remember that the user running this command should have sudo privileges in the parent directory.

For example, you want to remove an empty subdirectory named personal1 and its main folder mydir:

rmdir -p mydir/personal1

rm command -

The rm command is used to delete files within a directory. Make sure that the user performing this command has write permissions.

Remember the directory’s location as this will remove the file(s) and you can’t undo it.

Here’s the general syntax:

rm filename

To remove multiple files, enter the following command:

rm filename1 filename2 filename3

Here are some acceptable options you can add:

  • -i prompts system confirmation before deleting a file.

  • -f allows the system to remove without a confirmation.

  • -r deletes files and directories recursively.

touch command -

The touch command allows you to create an empty file or generate and modify a timestamp in the Linux command line.

For example, enter the following command to create an HTML file named Web in the Documents directory:

touch /home/username/Documents/Web.html

locate command -

The locate command can find a file in the database system.

Moreover, adding the -i argument will turn off case sensitivity, so you can search for a file even if you don’t remember its exact name.

To look for content that contains two or more words, use an asterisk (*). For example:

locate -i school*note

The command will search for files that contain the words school and note, whether they use uppercase or lowercase letters.

find command -

Use the find command to search for files within a specific directory and perform subsequent operations. Here’s the general syntax:

find [option] [path] [expression]

For example, you want to look for a file called notes.txt within the home directory and its subfolders:

find /home -name notes.txt

Here are other variations when using find:

  • find -name filename.txt to find files in the current directory.

  • find ./ -type d -name directoryname to look for directories.

grep command -

Another basic Linux command on the list is grep or global regular expression print. It lets you find a word by searching through all the texts in a specific file.

Once the grep command finds a match, it prints all lines that contain the specific pattern. This command helps filter through large log files.

For example, you want to search for the word blue in the notepad.txt file:

grep blue notepad.txt

The command’s output will display lines that contain blue.

df command -

Use the df command to report the system’s disk space usage, shown in percentage and kilobyte (KB). Here’s the general syntax:

df [options] [file]

For example, enter the following command if you want to see the current directory’s system disk space usage in a human-readable format:

df -h

These are some acceptable options to use:

  • df -m displays information on the file system usage in MBs.

  • df -k displays file system usage in KBs.

  • df -T shows the file system type in a new column.

du command -

If you want to check how much space a file or a directory takes up, use the du command. You can run this command to identify which part of the system uses the storage excessively.

Remember, you must specify the directory path when using the du command. For example, to check /home/user/Documents enter:

du /home/user/Documents

Adding a flag to the du command will modify the operation, such as:

  • -s offers the total size of a specified folder.

  • -m provides folder and file information in MB

  • k displays information in KB.

  • -h informs the last modification date of the displayed folders and files.

head command -

The head command allows you to view the first ten lines of a text. Adding an option lets you change the number of lines shown. The head command is also used to output piped data to the CLI.

Here’s the general syntax:

head [option] [file]

For instance, you want to view the first ten lines of note.txt, located in the current directory:

head note.txt

Below are some options you can add:

  • -n or –lines prints the first customized number of lines. For example, enter head -n 5 filename.txt to show the first five lines of filename.txt.

  • -c or –bytes prints the first customized number of bytes of each file.

  • -q or –quiet will not print headers specifying the file name.

tail command -

The tail command displays the last ten lines of a file. It allows users to check whether a file has new data or to read error messages.

Here’s the general format:

tail [option] [file]

For example, you want to show the last ten lines of the colors.txt file:

tail -n colors.txt

diff command -

Short for difference, the diff command compares two contents of a file line by line. After analyzing them, it will display the parts that do not match.

Programmers often use the diff command to alter a program instead of rewriting the entire source code.

Here’s the general format:

diff [option] file1 file2

For example, you want to compare two text files – note.txt and note_update.txt:

diff note.txt note_update.txt

Here are some acceptable options to add:

  • -c displays the difference between two files in a context form.

  • -u displays the output without redundant information.

  • -i makes the diff command case insensitive.

tar command -

The tar command archives multiple files into a TAR file – a common Linux format similar to ZIP, with optional compression.

Here’s the basic syntax:

tar [options] [archive_file] [file or directory to be archived]

For instance, you want to create a new TAR archive named newarchive.tar in the /home/user/Documents directory:

tar -cvf newarchive.tar /home/user/Documents

The tar command accepts many options, such as:

  • -x extracts a file.

  • -t lists the content of a file.

  • -u archives and adds to an existing archive file.

Check out the more practical examples to know more about the other functions.

chmod command -

chmod is a common command that modifies a file or directory’s read, write, and execute permissions. In Linux, each file is associated with three user classes – owner, group member, and others.

Here’s the basic syntax:

chmod [option] [permission] [file_name]

For example, the owner is currently the only one with full permissions to change note.txt. To allow group members and others to read, write, and execute the file, change it to the -rwxrwxrwx permission type, whose numeric value is 777:

chmod 777 note.txt

This command supports many options, including:

  • -c or –changes displays information when a change is made.

  • -f or –silent suppresses the error messages.

  • -v or –verbose displays a diagnostic for each processed file.

chown command -

The chown command lets you change the ownership of a file, directory, or symbolic link to a specified username.

Here’s the basic format:

chown [option] owner[:group] file(s)

For example, you want to make linuxuser2 the owner of filename.txt:

chown linuxuser2 filename.txt

jobs command-

A job is a process that the shell starts. The jobs command will display all the running processes along with their statuses. Remember that this command is only available in csh, bash, tcsh, and ksh shells.

This is the basic syntax:

jobs [options] jobID

To check the status of jobs in the current shell, simply enter jobs to the CLI.

Here are some options you can use:

  • -l lists process IDs along with their information.

  • -n lists jobs whose statuses have changed since the last notification.

  • -p lists process IDs only.

kill command -

Use the kill command to terminate an unresponsive program manually. It will signal misbehaving applications and instruct them to close their processes.

To kill a program, you must know its process identification number (PID). If you don’t know the PID, run the following command:

ps ux

After knowing what signal to use and the program’s PID, enter the following syntax:

kill [signal_option] pid

There are 64 signals that you can use, but these two are among the most commonly used:

  • SIGTERM requests a program to stop running and gives it some time to save all of its progress. The system will use this by default if you don’t specify the signal when entering the kill command.

  • SIGKILL forces programs to stop, and you will lose unsaved progress.

For example, the program’s PID is 63773, and you want to force it to stop:

kill SIGKILL 63773

ping command-

The ping command is one of the most used commands in Linux for checking whether a network or a server is reachable. In addition, it is used to troubleshoot various connectivity issues.

Here’s the general format:

ping [option] [hostname_or_IP_address]

For example, you want to know whether you can connect to Google and measure its response time:

ping google.com

wget command-

The Linux command line lets you download files from the internet using the wget command. It works in the background without hindering other running processes.

The wget command retrieves files using HTTP, HTTPS, and FTP protocols. It can perform recursive downloads, which transfer website parts by following directory structures and links, creating local versions of the web pages.

To use it, enter the following command:

wget [option] [url]

For example, enter the following command to download the latest version of WordPress:

wget wordpress.org/latest.zip

uname command -

The uname or unix name command will print detailed information about your Linux system and hardware. This includes the machine name, operating system, and kernel. To run this command, simply enter uname into your CLI.

Here’s the basic syntax:

uname [option]

These are the acceptable options to use:

  • -a prints all the system information.

  • -s prints the kernel name.

  • -n prints the system’s node hostname.

top command -

The top command in Linux Terminal will display all the running processes and a dynamic real-time view of the current system. It sums up the resource utilization, from CPU to memory usage.

The top command can also help you identify and terminate a process that may use too many system resources.

To run the command, simply enter top into the CLI.

history command -

With history, the system will list up to 500 previously executed commands, allowing you to reuse them without re-entering. Keep in mind that only users with sudo privileges can execute this command. How this utility runs also depends on which Linux shell you use.

To run it, enter the command below:

history [option]

This command supports many options, such as:

  • -c clears the complete history list.

  • -d offset deletes the history entry at the OFFSET position.

  • -a appends history lines.

man command -

The man command provides a user manual of any commands or utilities you can run in Terminal, including the name, description, and options.

It consists of nine sections:

  • Executable programs or shell commands

  • System calls

  • Library calls

  • Games

  • Special files

  • File formats and conventions

  • System administration commands

  • Kernel routines

  • Miscellaneous

To display the complete manual, enter:

man [command_name]

For example, you want to access the manual for the ls command:

man ls

Enter this command if you want to specify the displayed section:

man [option] [section_number] [command_name]

For instance, you want to see section 2 of the ls command manual:

man 2 ls

echo command -

The echo command is a built-in utility that displays a line of text or string using the standard output. Here’s the basic syntax:

echo [option] [string]

For example, you can display the text Avinash Blogeer by entering:

echo “Avinash Blogeer”

This command supports many options, such as:

  • -n displays the output without the trailing newline.

  • -e enables the interpretation of the following backslash escapes:

  • \a plays sound alert.

  • \b removes spaces in between a text.

  • \c produces no further output.

  • -E displays the default option and disables the interpretation of backslash escapes.

zip, unzip commands -

Use the zip command to compress your files into a ZIP file, a universal format commonly used on Linux. It can automatically choose the best compression ratio.

The zip command is also useful for archiving files and directories and reducing disk usage.

To use it, enter the following syntax:

zip [options] zipfile file1 file2….

For example, you have a file named note.txt that you want to compress into archive.zip in the current directory:

zip archive.zip note.txt

On the other hand, the unzip command extracts the zipped files from an archive. Here’s the general format:

unzip [option] file_name.zip

So, to unzip a file called archive.zip in the current directory, enter:

unzip archive.zip

hostname command -

Run the hostname command to know the system’s hostname. You can execute it with or without an option. Here’s the general syntax:

hostname [option]

There are many optional flags to use, including:

  • -a or –alias displays the hostname’s alias.

  • -A or –all-fqdns displays the machine’s Fully Qualified Domain Name (FQDN).

  • -i or –ip-address displays the machine’s IP address.

For example, enter the following command to know your computer’s IP address:

hostname -i

useradd, userdel commands -

Linux is a multi-user system, meaning more than one person can use it simultaneously. useradd is used to create a new account, while the passwd command allows you to add a password. Only those with root privileges or sudo can run the useradd command.

Here’s the basic syntax:

useradd [option] username

To set the password:

passwd the_password_combination

For example, to add a new person named John, enter the following command simultaneously:

useradd Avinash

passwd 123456789

To delete a user account, use the userdel command:

userdel username

Example - userdel Avinash

apt-get command -

apt-get is a command line tool for handling Advanced Package Tool (APT) libraries in Linux. It lets you retrieve information and bundles from authenticated sources to manage, update, remove, and install software and its dependencies.

Running the apt-get command requires you to use sudo or root privileges.

Here’s the main syntax:

apt-get [options] (command)

These are the most common commands you can add to apt-get:

  • update synchronizes the package files from their sources.

  • upgrade installs the latest version of all installed packages.

  • check updates the package cache and checks broken dependencies.

su command - switch user

The switch user or su command allows you to run a program as a different user. It changes the administrative account in the current log-in session. This command is especially beneficial for accessing the system through SSH or using the GUI display manager when the root user is unavailable.

Here’s the general syntax of the command:

su [options] [username [argument]]

When executed without any option or argument, the su command runs through root privileges. It will prompt you to authenticate and use the sudo privileges temporarily.

Here are some acceptable options to use:

  • -p or –preserve-environment keeps the same shell environment, consisting HOME, SHELL, USER, and LOGNAME.

  • -s or –shell lets you specify a different shell environment to run.

  • -l or –login runs a login script to switch to a different username. Executing it requires you to enter the user’s password.

htop command -

The htop command is an interactive program that monitors system resources and server processes in real time. It is available on most Linux distributions, and you can install it using the default package manager.

Compared to the top command, htop has many improvements and additional features, such as mouse operation and visual indicators.

To use it, run the following command:

htop [options]

You can also add options, such as:

  • -d or –delay shows the delay between updates in tenths of seconds.

  • -C or –no-color enables the monochrome mode.

  • -h or –help displays the help message and exit.

ps command - process status

The process status or ps command produces a snapshot of all running processes in your system. The static results are taken from the virtual files in the /proc file system.

Executing the ps command without an option or argument will list the running processes in the shell along with:

  • The unique process ID (PID)

  • The type of terminal (TTY)

  • The running time (TIME)

  • The command that launches the process (CMD)

Here are some acceptable options you can use:

  • -T displays all processes associated with the current shell session.

  • -u username lists processes associated with a specific user.

  • -A or -e shows all the running processes.

Linux Commands Tips and Tricks

  • Enter the clear command to clean the Terminal screen.

  • Press the Tab button to autofill after entering a command with an argument.

  • Use Ctrl + C to terminate a running command.

  • Press Ctrl + Z to pause a working command.

  • Use Ctrl + S to freeze your Terminal temporarily.

  • Press Ctrl + Q to undo the Terminal freeze.

  • Use Ctrl + A to move to the beginning of the line.

  • Press Ctrl + E to bring you to the end of the line.

  • When executing multiple commands in a single line, use (;) to separate them. Alternatively, use && to only allow the next command to run if the previous one is successful.

Â