# Linux for DevOps

**whoami command:**

The `whoami` command allows [Linux users](https://phoenixnap.com/glossary/what-is-linux) to see the currently logged-in use. The output displays the username of the effective user in the current shell

Additionally, `whoami` is useful in [bash scripting](https://phoenixnap.com/kb/write-bash-script) to show who is running the script.

`ubuntu@ip-172-31-46-198:~$ whoami`

`ubuntu`

**touch command:**

used to create, change and modify the timestamps of a file.

`ubuntu@ip-172-31-46-198:~$ touch example.txt`

`ubuntu@ip-172-31-46-198:~$ ls`

`example.txt`

**ls command :**

Checking the existing files using the command **ls.**

**Touch command to create multiple files:** The touch command can be used to create multiple numbers of files at the same time. These files would be empty while creation.

`ubuntu@ip-172-31-46-198:~$ touch abc.txt index.html style.css`

`ubuntu@ip-172-31-46-198:~$ ls`

`abc.txt example.txt index.html style.css`

pwd command:

the full path name of your current directory (from the root directory)

`ubuntu@ip-172-31-46-198:~$ pwd`

`/home/ubuntu`

the root directory is represented by the first /, and the last directory named is your current directory.

**mkdir command:**

mkdir command in Linux **allows the user to create directories.**(also referred to as **folders** in some operating systems)

`ubuntu@ip-172-31-46-198:~$ mkdir arif`

`ubuntu@ip-172-31-46-198:~$ ls`

`abc.txt arif example.txt index.html style.css`

**cd command:**

**cd** command in Linux known as the change directory command. It is used to move efficiently from the current working directory to different directories in our System.

`ubuntu@ip-172-31-46-198:~$ ls`

`abc.txt arif example.txt index.html style.css`

`ubuntu@ip-172-31-46-198:~$ pwd`

`/home/ubuntu`

`ubuntu@ip-172-31-46-198:~$ cd arif`

`ubuntu@ip-172-31-46-198:~/arif$ pwd`

`/home/ubuntu/arif`

cd .. command:

this command is used to go back to the previous directory

for example, we are in arif directory if want to go to the previous directory we use cd .. command

`ubuntu@ip-172-31-46-198:~/arif$ pwd`

`/home/ubuntu/arif`

`ubuntu@ip-172-31-46-198:~/arif$ cd ..`

`ubuntu@ip-172-31-46-198:~$ pwd /home/ubuntu`

now we are in the Ubuntu directory

**How to move file from one directory to another directory?**

`ubuntu@ip-172-31-46-198:~$ pwd`

`/home/ubuntu`

`ubuntu@ip-172-31-46-198:~$ ls`

`abc.txt arif example.txt index.html style.css`

In the ubuntu directory, we have file abc.txt to move that file to arif directory.

`ubuntu@ip-172-31-46-198:~$ cd arif`

`ubuntu@ip-172-31-46-198:~/arif$ mv ../abc.txt .`

`ubuntu@ip-172-31-46-198:~/arif$ ls`

`abc.txt`

**Nano command:**

Nano is similar like Notepad in our system in Linux we have nano

`ubuntu@ip-172-31-46-198:~/arif$ ls`

`abc.txt`

`ubuntu@ip-172-31-46-198:~/arif$ nano abc.txt`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692697180405/a29cc7a4-27a5-4330-9e2b-4227d045456f.png align="center")

After texting then press clt+x

then press save and enter

**cat command:**

this command is used to display content in that file

`ubuntu@ip-172-31-46-198:~/arif$ cat abc.txt`

`hello world !`

`I'm ARIF`

`ubuntu@ip-172-31-46-198:~/arif$`

**echo command:**

this command is similar to printf whatever we write in echo it will display

`ubuntu@ip-172-31-46-198:~/arif$ echo "hey everyone !"`

`hey everyone !`

rm command:

this command is used to remove any particular file for the folder

`ubuntu@ip-172-31-46-198:~/arif$ ls`

`abc.txt` [`abc.txt.save`](http://abc.txt.save)

`ubuntu@ip-172-31-46-198:~/arif$ rm` [`abc.txt.save`](http://abc.txt.save)

`ubuntu@ip-172-31-46-198:~/arif$ ls`

`abc.txt`

abc.txt.save file is removed.

**history command:**

this command is used to show what the command we are using for our activity

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692698583462/acd663c7-1a2c-4bf7-a379-a59569bf48da.png align="center")

**ls  -l Command:**

 - --&gt; regular file

 d --&gt; directory file

 b --&gt; block special file

 c --&gt; charecter special file

 l --&gt; linked file

 s --&gt; socket file

`arif@arif-ubuntu:~$ ls -l`

`total 48`

`drwxr-xr-x 7 arif arif 4096 Nov 16 12:06 Desktop`

`drwxr-xr-x 2 arif arif 4096 Oct 7 10:04 Documents`

`drwxr-xr-x 2 arif arif 4096 Nov 16 12:18 Downloads`

`-rw-rw-r-- 1 arif arif 0 Nov 17 14:40 example.txt`

`drwxrwxr-x 2 arif arif 4096 Oct 7 16:06 hhey`

**file command:**

`file <file name>--> to know the type of the file`

`arif@arif-ubuntu:~$ file example.txt`

`example.txt: empty`

`arif@arif-ubuntu:~$ vim example.txt`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1700212873896/086b6224-48c1-49e0-a1f6-ae0436209544.png align="center")

esc+ :wq + enter

`arif@arif-ubuntu:~$ file example.txt`

`example.txt: ASCII text`

**ls command:**

`arif@arif-ubuntu:~$ ls -p`

`Desktop/ example.txt` [`nano.7891.save`](http://nano.7891.save) `snap/ Videos/`

`Documents/ hhhhey/ Pictures/ Templates/`

`Downloads/ Music/ Public/ tmp/`

ls -l      --&gt; long listing or to see the properties of files and dir

            ls -p     --&gt; to identify the files and directories 

            ls -a     --&gt; to see the hidden files

            ls -s      --&gt; to see the size

            ls -i      --&gt; to see the inode numbers

            ls -sh    --&gt; to see the file size in human-readable format

I hope you find the blog post helpful! if you do, don't forget to like it.

And if you have any dought on the above topic you can ask me and make a connection with me.

happy learning
