Introduction to Essential Commands in Ubuntu Linux
Tags: ubuntu, linux
Published: 2024-05-27 01:21:24


<u>**uname** </u>
_The uname command provides information about the system, such as the kernel name, version._![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/shw4npynqx5zmjttz1x6.png)

---

**<u>uptime</u>**
_The uptime command shows how long the system has been running, the current time, the number of users logged on, and the system load averages._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqr8nnachfn18hogepar.png)

---

**<u>who</u>**
_The who command displays a list of users currently logged into the system._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6gzul6wew9lf2hmsegfz.png)

---

**<u>whoami</u>**
_The whoami command prints the username of the current user._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58or23lst9v6a22lfwtn.png)

---

**<u>which</u>**
_The which command locates the executable file associated with a given command by searching the directories listed in the PATH environment variable._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zofr84e4yhwuvobmwknn.png)

---


**<u>sudo apt-get update</u>**
_The sudo apt-get update command is used to update the local package index. This package index contains information about the available packages from the repositories configured on the system._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cbjzsqz9y2nap5iqlz1d.png)

---

_**User management in ubuntu linux**_

**<u>useradd</u>**
_The useradd command in Ubuntu is used to easily create a new user account,can provide password(recommend)_
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4kniakzt4ll3o4e9pw7a.png)

---

**<u>cat /etc/passwd</u>**
_The /etc/passwd file lists each user's username, UID, GID, home directory, and shell. It is essential for user account management._
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5r2xbmkeetlf7g3eo7ie.png)

---

**<u>groupadd</u> and <u>groupdel</u>**
_**groupadd** command is used to create a new group on a Linux system._ 
_**groupdel** This command is used to delete an existing group from a Linux system._ 
<u>**cat /etc/group**</u>
_the **cat /etc/group** command is used to display the contents of the /etc/group file. This file contains information about all the groups on the system._
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cggfa5938ylbwvenvcy0.jpg)

---

<u>**add user to group**</u>

_These commands use "usermod" to add existing users ("kali", "simon", and "ram") to the "learning" group on the system._

---

**<u>zipping directory</u>**
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3s8umhk8gmxveldgrk8d.png)
_the command **zip -r neww.zip klm/** creates a zip file named **neww.zip** containing all the files and directories within the **klm/** directory. Then, **ls** lists the files in the current directory, including **neww.zip**, indicating that the zip file was created successfully._

---

**<u>unzipping directory</u>**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fm0swu5jk1ui5zhr5gcj.png)
_copied a zip file named **neww.zip** from your home directory to a folder called unzipped within **/home/vagrant/klm/**. Then, you unzipped it, which contained a directory **klm/**along with its contents (tt.yxy, 11.txt, and haha.txt).( Tried to copy from Source to destination path and unzipped directory structure containing files_


**<u>file permission commands</u>**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bplb00z4e3r3ecbvhhub.png)
_changed the ownership of the directory "devops" to user "kali" using the **sudo chown** command_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0suyse6betpeyqu74cnc.png)
_changed the permissions of the "devops" directory to allow read, write, and execute access for all users._

---


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xeb7aeaiftjvb6fgz7c.png)
_created a file named "**abc.txt**" using **sudo touch abc.txt,** then listed the contents of the directory. After that,displayed the permissions of each entry using ls -1, which showed the "**abc.txt**" file along with the directories and their permissions.changed the group ownership of "**abc.txt**" to "**learning**" using **sudo chgrp learning abc.txt**, and then modified the permissions of "**abc.txt**" to 575 using sudo **chmod 575 abc.txt**.The final listing (ls -1) reflects these changes, showing the updated permissions for "**abc.txt**" and the directories._

---

**<u>Learn more about file permission</u>** 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ff6mevcn5nv0y8tsoj9o.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as0mnwm7k00xmwed95xv.jpg)
**an alternative way to change the permissions of a file in Linux to give read, write, and execute permissions to the user, group, and others.**
_<u>chmod a+rwx demo.sh </u>would give read, write, and execute permissions to all users (user, group, and others) on the file named <u>demo.sh_</u>
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/74td6ppsun1c4iyth56f.png)

---
_here g-wx remove the write and execute permission for group on demo.sh_
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo7e2zj6hexaiju5ibdd.png)

---
_here o-wx remove the write and execute permission for others on demo.sh_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rwte08qtng4n702ew3g.png)