"Linux for Beginners: Essential Commands and Why It's the Best OS"

"Linux for Beginners: Essential Commands and Why It's the Best OS"

Linux

Linux is an open-source Unix-like operating system-based family on the Linux kernel, and the OS kernel was first published on 17 September 1991 by Linus Torvalds. It is like Windows, Mac, Android, etc. and it used by 91% of the application on the internet.

Ubuntu, Debian, and Fedora are some popular Linux distributions. Also, we have RedHat Enterprise Linux for the commercial distribution of Linux. As it is open-source, we can modify the source code and make variations in the operating system.

Why use Linux?

  • Linux is compatible with virtually every hardware device, including Windows PCs and laptops, Macs, Windows tablets, Chromebooks, and non-Android phones and tablets.

  • It allows multi-user and multi-tasking capabilities.

  • It offers high security and doesn't require any antivirus software.

  • Linux is an open-source OS, meaning anyone can run and modify the source code for their own purposes.

  • Linux is famously reliable compared to other operating systems, with most users experiencing fewer issues. This reliability is due to Linux's strong focus on background process management, using processes only as long as necessary.

  • The best part? Linux is free! You can install the OS on as many platforms as you like at zero cost. Installing Linux is zero risk, high reward—the best of both worlds.

Basic Linux commands

  • Create a New File:
  touch filename

Example: touch file.txt

  • Copy a File:
cp source file destination

Example: cp file1.txt /path/to/destination

  • Move/Rename a File:
mv oldfilename newfilename

Example: mv oldfile.txt newfile.txt

  • Remove/Delete a File:
rm filename

Example: rm unwantedfile.txt

  • View Contents of a File:
cat filename

Example: cat file.txt

  • Edit a File:
nano filename

Example: nano file.txt

Directory Commands:

  • Create a New Directory:
mkdir directoryname

Example: mkdir mydirectory

  • Navigate to a Directory:
cd directoryname

Example: cd mydirectory

  • List Files and Directories:
 ls

Example: ls

  • List All Files and Directories (Including Hidden):
ls -a

Example: ls -a

  • Copy a Directory and its Contents:
mv olddirectory newdirectory

Example: mv olddir newdir

  • Remove/Delete an Empty Directory:
rmdir directoryname

Example: rmdir emptydir

  • Remove/Delete a Directory and its Contents:
rm -r directoryname

Example: rm -r unwanteddir

  • Check Your Present Working Directory:

The pwd command allows you to identify the current directory you are working in. Simply type pwd and press Enter to display the full path.

 pwd
 /home/username/documents
  • List All Files and Directories (Including Hidden Ones):

To list all files and directories in your current location, use the ls command. Adding the -a flag displays hidden files as well.

ls -a
  • Create a Nested Directory:

Building a nested directory structure is straightforward with the mkdir command. For example, to create a nested directory path A/B/C/D/E, use the following command:

mkdir -p A/B/C/D/E

The -p flag ensures that parent directories are created if they don't exist.