DEV Community

Cover image for Introduction to Essential Commands in Ubuntu Linux
Prajwal ps
Prajwal ps

Posted on

Introduction to Essential Commands in Ubuntu Linux

uname
The uname command provides information about the system, such as the kernel nam ine, version.Image description


uptime
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


who
The who command displays a list of users currently logged into the system.

Image description


whoami
The whoami command prints the username of the current user.

Image description


which
The which command locates the executable file associated with a given command by searching the directories listed in the PATH environment variable.

Image description


sudo apt-get update
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


User management in ubuntu linux

useradd
The useradd command in Ubuntu is used to easily create a new user account,can provide password(recommend)
Image description


cat /etc/passwd
The /etc/passwd file lists each user's username, UID, GID, home directory, and shell. It is essential for user account management.
Image description


groupadd and groupdel
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.
cat /etc/group
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


add user to group

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


zipping directory
Image description
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.


unzipping directory

Image description
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

file permission commands

Image description
changed the ownership of the directory "devops" to user "kali" using the sudo chown command

Image description
changed the permissions of the "devops" directory to allow read, write, and execute access for all users.


Image description
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.


Learn more about file permission

Image description

Image description
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.
chmod a+rwx demo.sh would give read, write, and execute permissions to all users (user, group, and others) on the file named demo.sh
Image description


here g-wx remove the write and execute permission for group on demo.sh
Image description


here o-wx remove the write and execute permission for others on demo.sh

Image description

Top comments (0)