Skip to main content

Command Palette

Search for a command to run...

Linux basics - Tutorial 1[redhat]

Updated
7 min readView as Markdown
Linux basics - Tutorial 1[redhat]
P
I am Instructional Designer with interest in Cloud Computing, Devops and Infrastructure management. I also write code to automate the boring stuff.

Redhat Linux Basics - Tutorial 1.

After going through this you will be comfortable in Linux terminal and basic linux commands.

Understanding the terminal

Linux user presence-root

What does the above picture show?

Let us understand each element one by one.
Content shown in the pic - [root@ip-172-31-16-22 ~]#.

  • root - This indicates you are logged in as root user

  • ip-172-31-16-22 - This shows the hostname

  • ~ - This indicates you are inside the home directory of root user. Ex. /home/root

  • '#' - This indicates you are logged-in as root user.

Note: / is called the root directory. It is the top most directory in Linux.

Command to display the username you are currently logged in as.

whoami

If you type this in the terminal you will get the current username as shown in the output below.

whoami-yolo-output

Command to display the hostname

hostname

If you type this in the terminal you will see the hostname as shown in the output below.

hostname-output

Command to switch user from root user to any user who is already there on system

su - username

If you type this in the terminal you will switch to the username as shown in the output below.

bancho-user-yosum

Command to switch from any user to root user

sudo -i

If you type this in the terminal you will switch to the root user as shown in the output below.

lobhichodon-root-huten

Command to print your current working directory

pwd

If you type this in the terminal you get the output as shown below

Hole ole lollei

.

Command to clear the terminal

clear

If you type this in the terminal you get the output as shown below

clear output

Note: To clear the terminal you can also use Ctrl+l

Command to see the history of all commands you executed in the terminal in the current session

history

If you type this in the terminal you get the output as shown below

history output

.

Command to see the manual of any linux command

man history

If you type this in the terminal you get the output as shown below

maual output

Note: To syntax is man <any_linux_command>. You open the manual of the command, then press q to exit out of manual..

Command to list files and directories

ls

If you type this in the terminal you get the output as shown below. This just lists the files and directories in the present working directory.

ls bitches

Command to long list files and directories

ls -l

If you type this in the terminal you get the output as shown below. This lists the files and directories in the present working directory with additional details.

long list bitches

Command to list all files and directories along with hidden files also.

ls -a

If you type this in the terminal you get the output as shown below. Shows all files, including hidden files and directories (those whose names start with a .)

ls encrypted

Command to see the current date and timestamp

date

If you type this in the terminal you get the output as shown below.

date-time

Command to change directory. Syntax cd your-directory-name.

cd ubuntu

If you type this in the terminal you get the output as shown below. This navigates you to ubuntu directory.

navigate folder

Note: There are many things you can do with cd command using paramaters. Let me show you some below. Please explore on your own also.

Command to change directory.

cd /

If you type this in the terminal you get the output as shown below. This navigates you to root directory.

root directory

Command to change directory.

cd ~

If you type this in the terminal you get the output as shown below. This navigates you to user's home directory.

users home directory

Command to change directory.

cd -

If you type this in the terminal you get the output as shown below. This navigates you to user's previous working directory.

previous-directory

You can also use.

cd ..

Understand Important Directories

/

Root directory

/home

Users' home directories

~

Current user's home directory

/root

Root user's home directory

Command to display calender.

cal

If you type this in the terminal you get the output as shown below.

see the dates

Create single directory

mkdir demo

Create multiple directories

mkdir dir1 dir2 dir3

If you type this in the terminal you get the output as shown below.

directories

Remove Empty Directory

rmdir demo

If you type this in the terminal you get the output as shown below.

remove folder

Create Empty Files

touch file1.txt

Create Multiple files

touch file11.txt file2.txt file3.txt

If you type this in the terminal you get the output as shown below.

files created

Remove a file or multiple files

rm file11.txt file2.txt file3.txt

If you type this in the terminal you get the output as shown below.

dletedfiles

Create a directory or multiple directories

mkdir newfolder

If you type this in the terminal you get the output as shown below.

Directoies

Delete a empty directory or multiple directories

rmdir fol1 fol2 fol3

If you type this in the terminal you get the output as shown below.

Delete direc

Delete a directory with content inside

rm -rf ubuntu

If you type this in the terminal you get the output as shown below.

force delete

Note: This is also the command to perform a force delete..

To know location of any command or software

which ls
which python

If you type this in the terminal you get the output as shown below.

which man

To know location of file or folder

find newfolder

If you type this in the terminal you get the output as shown below.

find-this

To write contents in a file

nano mytextfile 

After typying the text save and exit using Ctrl+x and Enter keys on keyboard. Keep in mind nano editor is used here, you can also explore and learn about vim editor.

If you type this in the terminal you get the output as shown below.

Screenshot 2026-07-27 at 9.07.30 PM

To see the contents of a file

cat mytextfile

If you type this in the terminal you get the output as shown below.

I said 23

To find a word in a file use grep

grep linux mytextfile
grep -i Linux mytextfile #ignores case sensitive

If you type this in the terminal you get the output as shown below.

Screenshot 2026-07-27 at 9.15.22 PM

With this we come to the end of the tutorial 1 of Linux. Thank you for going through this. See you all in part two.. Until then Happy Learning 😀

S

Good for beginners , nice work Pritam Pal