Linux – Making It Easier To Learn


Say it a rumor or some statements to maintain the competition in market, Linux is always cursed with messy words. But the reality is far beyond this. Linux is a smoother and most popular Operating System in the arena of OS these days. It was a product of neglect, a student faced in his pupil life when he was using Unix as an Operating System and advised some improvements. Linus Torvalds was completing his professional degree of Computer Sciences when he presented an idea of launching a modified version of existed Operating System i.e. UNIX.

Being the victim of misperceptions, users of other Operating System deprived of the taste of working on Linux-Based Operating System. Very simple to use and easy to interpret, Linux has its own class of performance. Linux is an Open-Source Operating System which provides a wide range of functionality and freedom of work to its users with high-level security under reliable mode of tasks. This is the reason why programmers and Cyber Security Specialists prefer the Linux-Based OS.

If you’re crawling through this tutorial, it is considered that you must have a mind to switch from any other OS to Linux or you’re a professional, looking for some ways to boost up your skills upto advanced levels.

Tada, Congratulations! You reached to a station where this tutorial is going to outline some queries (We call it command-lines) to portray an image of entire article.

So, You’re going to learn…

  • Which file contains a list of the users on a Linux-Based OS?
  • How to list all users
  • Listing users sorted by name
  • Listing users without password
  • Listing users’ disk usage
  • Listing users that have access to folder
  • Listing the users currently logged in
  • Listing users who logged on the system by specific date
  • Listing users who recently logged into system
  • Listing all users in a group
  • Listing users with UID – User Identifier
  • Listing root users
  • Listing total number of users
  • Listing sudo users
  • Printing list of users who have Permissions for a file
  • Listing locked users in linux

Which file contains a list of the users on a Linux-Based OS?
            Multitasking becomes a necessity these days and this is what the Linux was designed for, allowing multiple users to gain access over the system at same time. Linux stores the data of these users in a file to make it easier to find users under Linux-Based OS. User Information is saved in a file i.e. /etc/passwd.




How to list all users

To find out the information, containing a list of the users on a Linux-Based OS a very simple command-line is used with the combination of /etc/passwd. Lets make some sub-division to have better understanding of the topic.

Step 1: Opening Terminal
There can be several ways to open terminal in Linux-Based OS, listed below.

  1. Using Ctrl+Alt+T keys at once in Ubuntu to open terminal.


2. Terminal in Ubuntu can be opened by searching in Ubuntu Search Bar which can be opened in Dashboard.



3. For the sake of easier approach, Another way of switching to terminal can be through the dashboard icon.




Step 2: After opening the Terminal, you’ll see a black window with some colored text in it. (as shown below.


 
Then start writing the command-line starting from the white thick courser. Here an extension is used to get the output from file i.e. cat or less. Enter the command as shown below:

$ less /etc/passwd




As we got the result above, seven fields that are delimited by the colon “:”  can be observed in the case. Below is the explanation for each field.

  1. UserName
  2. Encrypted Password – Represented by x
  3. User’s ID
  4. User’s Group ID
  5. GECOS i.e. full name of the user.
  6. Home Directory
  7. Bin/Bash – Default Login Shells

another command can also be used to display the file. You may enter the following command-line to get the results.

$ cat /etc/passwd




Tip: To grab the username only you can use either awk or cut with /etc/passwd file command as well. Enter the command as written below.

awk -F: '{ print $1}' /etc/passwd



Listing users sorted by name
               Looking to have output by username? Don’t worry! Under this heading, we’ll discuss step by step about how to list users, sorted by name.

Step 1: Opening Terminal
(As discussed earlier)

Step 2: Typing Command.
After opening terminal, type command i.e. whoami to grab the desired output. Enter the  command-line as listed below.

$ whoami




Here, the command who works as an element to list all the users with their names on the directory.

Option 2: Detailed Information  With Username
Detailed information as an output can be grabbed out through using who.




Listing users without password
             Scratching your head and kind find anyway to list users without password? But there can be several questions arising out of the topic whether is it possible to create a user without password in linux or what could be the best way to create a user without password. But sticking to the topic, Here is the solution for your problem.

Step 1: Opening Terminal: 
(As discussed earlier)

Step 2: Typing Command:
To find users without password, getent command can be used with the combination several commands to extract the desired product. Enter the command in the terminal as written below.

sudo getent shadow | grep '^[^:]*:.\?:' | cut -d: -f1



Listing Users’ Disk Usage
Due to variety of functionality, linux provides several option depending on the format, for listing User’s Disk Usage. Following are the command to check the disk usage of users.

1.      df command: This command is usually used to show the disk space in two form i.e. used and available.
2.      du command:  du command is certainly specified and used to show the measure of specific files and sub-directories.

Lets talk about the commands in separate step to learn more about them.

df command :

Step 1: Opening Terminal:
(as discusses above)

Step 2:  type the command df to get the following results.




Step 3 (Another Option):
Another option to get the disk usage can be the option of -h with the combination of df to get another formatted result.



du command :

Tracking disk space hogs can be easier with du command.   du command is used to extract the names of diectories and files that consume large disk space.




du command can also be used in the combination with -h.



Listing Users That Have Access to Folder:
Under the heading of Accesses and Permissions, Before moving towards commands, I’ll try to explain about the Concept of Permissions in Linux to get a better insight of why is it necessary to have permissions to access folders and files.
As Linux was designed to perform Multi-user task, so it becomes necessary to take control over administrative part and authorize who can access and who couldn’t. Here, the phenomena of Permissions developed to provide a total support and security to the entities.
Actually, Permissions are considered to be the ‘Rights’ which are to be used when trying to access file or directory. Reading, Writing and Executing are the basic rights under Permissions’ domain.

To find the users, having access to folder we may break down the process into some steps as following:

Step 1: Opening Terminal
(As discussed earlier)

Step 2: Typing Command
To find out the users access to folder, ls command is typed with the combination of -l in the terminal to list users having access to folders. type the command as listed below.

ls -l

In this case;
- “r” refers to read permission.
- “w” refers to write permission.
- “x” refers to execute permission.
- “shah” refers to usersname.
- Date is mentioned in MM/DD/YYYY format.
- Blue colored text refers to file and directory.


Listing The Users Currently Logged In
A multi-user OS needs a high level of management due to its diversified range of task happening at same time. Parallel to Multi-tasking, it is essential to be the most responsive to become the pulse into the arena. And yes, this is what Linux-Based Operating System are designed for, where you can grab every detail on your fingers just by pressing some keys so you don’t have to worry about switching windows.

So, Detailed information about current user i.e. logged in currently as an output, can be grabbed out through using who. Type the command as shown below and you’ll be amazed by having the result as shown in screenshots attached below.

$ who


Listing Users Who Logged On The System By Specific Date
Sometimes, it is not less then a relief when without switching windows or working for hours to find specific data become as easier as typing a short command and you get what you want. Linux is blessing, really. If you wanted to find a specific data from your computer, just open the terminal and write a command, Hurrah! Here you get what you needed.
Lets simplify the process into some step so it would become a DIY type work.

Step 1: Opening Terminal
(As Discussed Above)

Step 2: Analyzing and Typing Command
At second step, before writing command one should  know that this command is composed of 4 part i.e. last, grep, -i and day (i.e. Mon).
 Type the command a shown below.

$ last | grep -i Mon



And here is the screenshot of what result shall be yielded after typing the command.




Listing Users Who Recently Logged Into System
Are you looking for a command to find details for who logged into the system recently and can’t find way? This tutorial is here to solve your problem. Just as far as typing a command and you’ll reach your destination.
For your convenience, this topic is described in some stages so you can execute the it as following.

Step 1: Opening Terminal
(As Discussed Below)

Step 2: Typing Command
A command i.e. last is used to print all the recent logins into the system. Type the command below.

$ last



For the sake of output, Screenshot is attached below to find out the way if you’re going straight.




OR

$ last | less



And here you go with the output attached as a screenshot


.


Listing All Users In A Group
Talking about Users in a Group may unveil the categorization of Users’ structure as it can be divided into three main categories;
·         Administrator’s Account/User i.e. root user
·         Regular Account/User
·         System Account/User
It can be discussed that what properties create a authoritative wall between these users’ type. And the answer is very simple, their extent of access.
An Administrator’s Account i.e. root user can be termed as the King who has the highest control over system which may include setting up the programs i.e. to create, delete, modify and so on. On the other hand, Regular Account i.e. normal user account is a type of account that has moderate controls over system so security of the system shall be assured. And Finally, the System User – Governed by the programs along who’s installation, the System user took birth. They can’t be used for either purpose and only works for the boss i.e. the program.

After explaining Users, now it is easy for me to say that the group is combination of Users to make the work convenient. Wonder, how are you going to list the user in group? Don’t worry. Lets fragment the task into a list of steps.

Step 1: Opening Terminal
(as discusses earlier)

Step 2: Typing Command
There can be several methods to enlist users in a group depending on the functionality and specification you need.


Option 1: Using /etc/group
If you need the results in a general format, you need to type group command in combination with /etc. type the command as following.

$ cat /etc/group




Below is the attachment to check if you’re getting an appropriate result or not.


Option 2: Using getent command
You can also enlist users in a group by using getent command. Type the command as shown below.

$ getent group group_name






Screenshot is attached to know if you’re working executing command in a right way.



Here,
-  sudo indicates the group name.


Listing users with UID – User Identifier
as discussed above in users’ details, users are assigned with specific numerical IDs. Lets find out how to list users with UID.

Open up the terminal and type the following command as shown below to extract the results.



Here is the attachment (screenshot) for the results.




Listing Root Users in Linux
When it comes to specifying something, Linux take the process at pro level. Just type the following command in following pattern using group_name to yield the result. Type the command in following pattern.

$ grep '^sudo:.*$' /etc/group | cut -d: -f4




and here you can check the results in as attachment.



Here,
- Shah is considered as a User in group sudo
Listing sudo Users
root user and sudo user might be confusing at sometimes, but this tutorials is going to erase this confusion with ease. Let say, The computer is my own property and I installed the distribution i.e. Ubuntu and setup the OS meanwhile I put myself as an adminitrator. So I’ll be considered as root user whereas if any of my friend wants to work as an admin to perform a particular task then he would be considered as sudo.

Listing Total Number of Users in Linux
lets work on listing total number of user that are using the system as operators. Simply open the terminal and type command. How easy!

Type the command with the combination of getent as shown below.

$  getent passwd | wc -l


and here you go with what you needed.

Here,
- 44 indicates the number of users allover.


Printing list of users who have Permissions for a file
Open the terminal and type the command, Simple!
Type the command as following.

$ ls -ld
and here you go with the results.






Post a Comment

0 Comments