Integrated Tech Solutions

Top 5 Linux Commands for Beginners [With Examples]

By - Admin February 21, 2024

If you’re here that means you’re a web developer. If you’re a web developer, you might have worked on uploading files to the server using FTP Client softwares or CPanel Filemanager. Have you ever used SSH client like putty to dive deeper in the server

Why do we need commands for Linux?

Unlike MacOS & Windows, Linux operating systems are not supposed to be used by normal Home users. Linux OS is widely used by technically advanced users like programmers, hackers, etc.

Where do we run Linux Commands?

There are certain programs that are specifically meant to run commands. For example in MacOS, it is Terminal. Linux comes with a Command line interface, windows come with a command prompt & PowerShell.

Linux Commands for Files

See Contents of a Directory

We can use the “ls” Command to see the contents of the current directory

$ ls

Edit a Text file

We can open/edit any text file using the nano editor with the nano command as shown below –

$ sudo nano filename.html

after running the nano command, a file editor will open. You can make your desired changes there.

Once you’re done with the changes you can save the file by pressing Ctrl + X . It will then ask whether to save the changes or not.
Press Y and hit enter and your file will be saved.

Copy/Move a Text File

You can easily copy a file to a new destination using the cp command as shown below –

$ sudo cp index.html /var/www/html/index.html

After executing this command, the index.html file will be copied to the index.html file in /var/www/html directory.

Remove a Text File

You can remove any file using rm command in linux as shown below –

$ sudo rm filename.php

To remove a directory however, you need to use the rmdir command as shown below –

$ sudo rmdir directory_path

Please note the above command will not execute if the directory is not empty.

To remove a non-empty directory in linux, we need to use the -rf parameter with rmdir command –

$sudo rmdir -rf directory_path

This command will remove the specified directory

Change File Permissions

You can easily change file permissions in Linux using the chmod command –

$ sudo chmod 644 filename.html

Similarly, you can change the permissions of a directory also.

But to change the file permissions of all contents of a directory, we need to specify the recrussion flag by -R parameter as shown below –

$ sudo chmod -R 755 directory_path

Change the Owner of a File/Folder

we can change the owner of a file using the chown command –

$ sudo chown ubuntu:ubuntu filename.html

Please note, in chown command above, user & group are separated by “:”.

Name on the left of: is the user, while on the right is a group. These two can be the same or different depending on the requirement.

Again, to change owner of a directory & its contents we need to specify the -R parameter as shown below –

$ sudo chown -R ubuntu:ubuntu directory_path

Date Time Setup in Linux

On a linux server, by default the time is set to Universal Time zone(UTC).

You can set a specific timezone using the timedatectl command as shown below –

timedatectl set-timezone "Asia/Kolkata"

Linux Commands Video Tutorial

Top 10 Linux Commands

What is SSH?

SSH stands for Secure Shell

A Protocol for remote login to server securely through command line or Terminal.

SSH is a globally used protocol to run Linux commands on remote servers from the Command line interface.

SSH Connection on windows

We have to install a program called SSH Client to access the server via SSH.

Putty is one of the most popular SSH Client for windows. Download and install Putty to access a server over SSH.

How to make an SSH connection?

After installing Putty, you can use your terminal or built-in command-line in putty. To connect to your server via SSH you need 3 things-

  1. IP Address of server
  2. FTP Credentials
  3. Port (Provided by hosting Provider)

To make your first SSH Connection type in the command line –

ssh root@34.465.876.87

Then it will ask for password, enter the password and you’ll see the welcome message.

How SSH actually works?

There are certain commands for ssh to perform certain actions like creating a directory or removing one etc.

Some basic SSH commands are listed below –

ls [directory] #To view the contents of a directory
rm [directory] #to remove a directory
cd [directory] #to enter another directory
mkdir [directory] #to make a new directory
touch [filename] #to create a file in the new directory.
.
.
The list goes on.

ls Command – To show the contents of a directory

ssh command to show content list

Some additional options to use with ls command-
-a display the hidden files and filenames starting with dot.
-l display additional details of files like file size, permissions and date modified.
-s Shows the filesize in blocks.

cd Command – To change the current directory

ssh command to change current directory

Touch Command to make a new file

ssh command to make new file

mv Command – To Move a file to new location

mv command ssh

mkdir Command – To Make a new Directory

ssh command mkdir

Wget Command – To download a file from the internet

wget command in ssh

How to enable ssh as an additional feature in windows 10

In the settings app, go to Manage Additional Features.

Click the Add a Feature button. From the list of available options, select OpenSSH server and click install.

How to run SSH Commands on AWS with PEM file

Amazon Web Services is one of the most reliable and high performing cloud services provider.
On AWS, you have to download a key pair file also called pem file.

SSH -i Command for AWS

How to fix Permissions too Open Error

Source – https://www.yobyot.com/

It’s obvious when you try to connect to an AWS instance using a PEM file, it shows Permissions too Open Error. In linux, you can run the CHMOD 400 command to change permissions of the file. But in windows, it’s slightly tricky

Open Windows Powershell & Run the following Commands to make file permissions 400 in windows –

C:\Downloads\Key-Location> icacls.exe keyname.pem /reset
C:\Downloads\Key-Location> icacls.exe keyname.pem /grant:r “$($env:username):(r)”
C:\Downloads\Key-Location> icacls.exe keyname.pem /inheritance:r

Leave a Message

Registration isn't required.




By commenting you accept the Privacy Policy

Keep Reading

👋 Hi, Find this Helpful? There is More

You Asked,
We made it!

fix japanese keyword hack

Step by Step Video Tutorials on trending topics in software development

Yes I am Curious »

5 Tips to Pick the Most Engaging Live Chat for Your Website

In today’s fast-paced digital world, providing excellent customer service is a key differentiator for businesses. One of the most effective...

Know More »
next js deployed on aws

Beginners Guide to deploy NextJs App on AWS EC2 Server

In this blog post, we will walk you through the step-by-step process of deploying a Next.js application on an AWS...

Know More »