Thursday, 30 November 2023   |

how to find username in centos using command


To find the username in CentOS using the command line, you can use the `whoami` command. Here's how:

1. Open a terminal or connect to your CentOS server via SSH.
2. Type the following command and press Enter:

```
whoami
```

3. The command will output the username associated with the current session.

Alternatively, if you want to find a list of all usernames on the system, you can use the `cut` and `sort` commands in combination with the `/etc/passwd` file. Here's how:

1. Open a terminal or connect to your CentOS server via SSH.
2. Type the following command and press Enter:

```
cut -d: -f1 /etc/passwd | sort
```

3. The command will display a sorted list of all usernames on your CentOS system.

Note that you may need administrative privileges (root access or sudo) to view all usernames on the system, as the `/etc/passwd` file is typically readable only by privileged users.


Date: 13 June 2023    Comments: 1


Comments - 1

ronak

cool


Leave A Comment