What is Linux? Linux Origins| Essential Basic Key Commands

What is Linux? Linux Origins| Essential Basic  Key Commands

Introduction

In the realm of operating systems, Linux stands as a prominent and versatile contender, offering unparalleled flexibility, security, and customization options. Whether you're a tech enthusiast, a developer, or a system administrator, understanding Linux's fundamentals and essential commands is crucial. In this blog post, we'll delve into the world of Linux, and its origins, and provide you with a primer on some basic and important commands that every Linux user must know.

What is Linux?

Linux is an open-source, Unix-like operating system kernel that serves as the foundation for various Linux distributions (distros). Unlike proprietary operating systems, Linux is developed collaboratively by a vast community of contributors. Its open nature allows developers to customize, modify, and distribute it freely, which has led to the creation of a multitude of Linux distros tailored for specific purposes.

Origins of Linux

The story of Linux begins with Linus Torvalds, a Finnish computer science student. In 1991, Torvalds initiated the development of Linux as a personal project to create a free alternative to the MINIX operating system. He released the first version of the Linux kernel, which attracted the attention of other developers worldwide. This collaborative effort led to the rapid growth and evolution of Linux into the powerful and versatile system we know today.

Basic Key Commands in Linux

ls command

If you wish to list files or directories within the file system of Linux OS, then the ls command (short for List) is the solution. Using this command, you have a variety of options such as the following table:

Option

Description

ls ~

It gives the contents of the home directory

ls ../

It gives the contents of the parent directory

ls –version

It checks the version of the ls command

ls -a

list all files including hidden files starting with ‘.’

ls –color

Colored list [=always/never/auto]

ls -d

list directories – with ‘ /’

ls -F

Shows file types (“/” = directory, “” = executable)

ls -li

If the file is the first column, then this command prints the index number

ls -l

list with long format (permissions, size, ownership, and modification date)

ls -laF

list long format including hidden files

ls -lh

list long format list with size displayed using human-readable file units (KB, MB, GB)

ls -ls

list with long format with the file size (descending)

ls -r

list in reverse order

ls -R

list recursively directory tree

ls -s

list file size

ls -S

sort by file size

ls -t

sort by modification time & date – it will open the last file you edited

ls -X

sort by extension name

pwd command

It show the present working directory. Here is the syntax:

$ pwd [option]

pwd is one of the basic Linux commands cheat sheets. This command has two flags:

Pwd –L

Displays the current working directory logical path with the symbolic link name.

Pwd –P

Displays the current working directory physical path without the symbolic link name.

cd command

This command will change your current directory in Linux and other Unix-like operating systems. In other words, the cd (short for Change Directory) command is one of the most frequently used and one of the basic Linux commands that is used on the Linux terminal. The syntax for this command is:

cd [options] directory

directory (one level up), you would type:

cd . ./

mv command

This command is used to move one or more files or directories from one place to another. Following is the syntax of this Linux basic command with a few examples:

mv [option] SOURCE DESTINATION

The SOURCE can be one or more directories or files, and the DESTINATION must be a single directory or file. To move a directory or file, you need to write permissions on both SOURCE and DESTINATION. Otherwise, you will receive a permission denied error.

If you want to just rename a file, type the following syntax:

mv [filename] [new_filename]

For example:

mv names.txt fullnames.txt

Similarly, if you want to move a file to a new location, use the following syntax:

mv [filename] [dest-dir]

For example:

mv fullnames.txt /home/routerhosting1/Downloads

cat command

The cat (short for concatenate) command is one of the most frequently used and one of the basic Linux commands that allows users to create single or multiple files, concatenate files, view contents of files, and redirect outputs in files or terminals. The typical syntax of this command is something like this:

cat [option] [file] . . .

he following table shows the main options for using the cat command:

option

description

cat test

Displays the contents of a file

cat test1 test2

Displays the contents of test1 and test2

cat test1; teat2; test3

Displays multiple files at once

cat -b

adds line numbers to non-blank lines

cat -n filename

Shows contents and adds line numbers to all lines

cat -s

Squeezes blank lines to one line

cat -e

Shows $ at the end of the line. Good for squeezing multiple lines in a single line

cat –T test

shows ^I instead of tabs

cat test1 teat2 test3 > test4

Redirecting multiple file’s contents in a single file

cat > test1

Will create a file named test1

cat test1 >> test2

Will append the contents of one file to the end of another file

cp command

The cp command stands for COPY. This command can copy a single or a group of files or directories. It requires at least two filenames in its argument. Syntax of this command can be something like the following:

cp [option] Source Destination
cp [option] Source Directory
cp [option] Source-1 Source-2 Source-3 Source-n Directory

The first and second syntax is used for copying the source file to the destination or directory. The third syntax is used for copying multiple files (sources) to the directory.

mkdir command

This Linux command allows users to make new directories. With mkdir command, you can also set permissions, and create multiple folders at once. The syntax of this command for making a single directory is something like this:

mkdir [option] dir-name

rm command

When you are going to remove directories and the contents within them, the rm command is the solution. But, if you only want to delete the directory, use rm –r. The syntax is something like the following short-code:

rm [option] FILE

Touch command

The touch command is known as another Linux basic command that lets you create a new blank file.

Syntax: touch file_name

touch

Example: touch /Home /username/Documents/Me.txt

This command creates a single text file in the destination address (documents). If you want to create multiple files in a particular destination.

Syntax: touch File1_name File2_name File3_name

df command

The Df command stands for “Disk Free,” which gives you the system detail as a report, such as the amount of disk, space, and usage.

To view the readable disk space summary, you can receive it in bytes, megabytes, and gigabyte format.

E.g.: MegaBytes:

df -m

Options:

touch –a: This command can change access time to a specific file. It is recommended to modify or update the last access times of a file

Syntax:

  • df

  • df /dir

  • df [option] [/dev/DEVICE]


Summary

CommandDescription
lsLists files and directories in the current directory.
cdChanges the current working directory.
pwdDisplays the present working directory.
mkdirCreates a new directory.
rmRemoves files or directories. Be cautious with -r option.
cpCopies files or directories.
mvMoves or renames files and directories.
touchCreates an empty file.
nano / viText editors for creating and editing files.
chmodChanges file permissions.
chownChanges ownership of a file or directory.
psDisplays information about currently running processes.
topOffers a real-time view of system processes.

Feel free to refer to this table as a quick reference for these basic Linux commands.


Conclusion

Linux has come a long way since its inception, evolving into a robust and versatile operating system that powers a wide range of devices, from servers and smartphones to embedded systems. Understanding the basics of Linux and its essential commands is a valuable skill for anyone venturing into the world of technology, development, or system administration. As you delve deeper into Linux, you'll discover its rich ecosystem of tools, applications, and possibilities, making it an exciting platform to explore and master.