Thursday, October 20, 2016

Change the Password of Any Linux User from the Terminal on Linux

If you're a system administrator and you want to change the password of a user of your Linux system, follow this tutorial.

Let's say I have a user 'linda' on my system. I want to change the password of linda. I would run the following command,

sudo passwd linda
Changing password for shovon.
(current) UNIX password:

Enter your current accounts password and press <Enter>. Then you will see the following prompt:

Enter new UNIX password: 

Enter the password that you want 'linda' to have and press <Enter>, Then you will see the following prompt:

Retype new UNIX password: 

Retype the new password for 'linda' and press <Enter>. You will see the following line.

passwd: password updated successfully 


Congrats! You have successfully changed the password of 'linda' from Linux terminal.

Change Your Password on Linux

If you want to change your password from the terminal on Linux, follow this tutorial.

To change your password on linux, run the following command

passwd
Changing password for shovon.
(current) UNIX password:

Enter your current accounts password and press <Enter>. Then you will see the following prompt:

Enter new UNIX password: 

Enter the password that you want your account to have and press <Enter>, Then you will see the following prompt:

Retype new UNIX password: 

Retype your new password and press <Enter>. You will see the following line.

passwd: password updated successfully 


Congrats! You have successfully changed your password from Linux terminal.

Enable root account on Linux

To enable root account, you must have administrative privileges. Usually what that means is, you must be a sudoer. sudoers can run sudo command.

To enable root account run the following command,

sudo passwd
[sudo] password for shovon: 

Enter your current accounts password and press <Enter>. Then you will see the following prompt:

Enter new UNIX password: 

Enter the password that you want root account to have and press <Enter>, Then you will see the following prompt:

Retype new UNIX password: 

Retype the root password and press <Enter>. You will see the following line.

passwd: password updated successfully 


Congrats! You have successfully enabled root account.

Change root Password of Linux

To change the root password run the following command,

sudo passwd
[sudo] password for shovon: 

Enter your current account's password and press <Enter>. Then you will see the following prompt:

Enter new UNIX password: 

Enter the password that you want root account to have and press <Enter>, Then you will see the following prompt:

Retype new UNIX password: 

Retype the root password and press <Enter>. You will see the following line.

passwd: password updated successfully 


Congrats! You have successfully changed the root password.

Monday, October 17, 2016

See Which Processes are Consuming Most of Your Physical Memory/RAM on Linux

To view the processes that are using your RAM use the following command,

sudo ps aux | awk '{print $2 " " $6}' | sort -k2,2 -nr | grep -v 0 | grep -v RSS
1963 82432
2928 39884
3634 32112
3253 28792
2868 28764
3247 27952
3255 27524
3257 18116
2994 15688
2867 14196
1769 13988
1883 12744
2827 9656
1762 8228
2775 8116
2784 7232
2797 6436
3225 6424
1 5676
3354 5484
617 5184
3217 5112
3287 4884
1645 4836
2525 4296
3976 3984
3977 3384
1731 3332
571 3272
1766 3196
1738 2988
2869 2984
1997 2484
2251 1864
2496 1832
1761 1276
3979 936
1771 856
3978 768
2547 316

The first column is the PID(process ID) and the second column is the amount of RAM(in kilobytes) used by that process.



If you want to view the top 5 process from that big list, you can use the following command,

sudo ps aux | awk '{print $2 " " $6}' | sort -k2,2 -nr | grep -v 0 | grep -v RSS | head -n 5
1963 82432
2928 39884
3634 32112
3253 28792
2868 28764

Here 1963 is the PID(process ID) and it is using 82432KB of the physical memory(RAM).



If you want to know more about the process, you can use the PID like this,

sudo ps p 1963
 PID TTY      STAT   TIME COMMAND
1963 tty7     Ss+    0:37 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0

Here 1963 is the PID of the process.

See Which Process is Using Most of Your CPU on Linux

To view the processes that are using your CPU use the following command,

sudo ps aux | awk '{print $2 " " $3}' | sort -k 2,2 -nr | grep -v 0.0 | grep -v %CPU
3656 1.5
1963 1.4
3634 0.4
2548 0.3
3251 0.1
3247 0.1
1 0.1

The first column is the PID(process ID) and the second column is the percentage of CPU used by that process.

If you want to view only the process that is using most of the CPU, you can use the following command,

sudo ps aux | awk '{print $2 " " $3}' | sort -k 2,2 -nr | grep -v 0.0 | grep -v %CPU | head -n 1
3656 1.5

Here 3656 is the PID(process ID) and it is using 1.5% of the CPU. On a real server, percentage of CPU usage might be way higher than that.

Saturday, October 15, 2016

Unlock User Account (Enable User Login) on Linux

To unlock a user account that has been locked on linux, you can use the passwd command.

The command is,

sudo passwd -u username

For example, to unlock the user 'linda', so 'linda' can login to the system again,

sudo passwd -u linda
Unlocking password for user linda.
passwd: Success

Now you can try to login as 'linda' and you will see that login is working again.