We can set up automatic logout for root session so that session gets logged off, if it is idle for a while. It is important to know this as any sneaker can misuse the situation, when a root user leaves the session idle. The method is very simple and as follows:
01. Locate the system file
#nano .bashrc
02. Go to under the “#user specific aliases and functions” line and then type
TMOUT=60
03. Save this file
Ctrl + O
04. Exit the file
Ctrl + X
Here TMOUT is an environment variable which instructs the bash shell to exit if the session is idle. Here timeout is set as 300 seconds (5 minutes).
------------------------------------------------------------------------------------------
Tuesday, 23 February 2010
How to disable interactive startup in linux
01. Login as root
02. Edit this system file
#nano /etc/sysconfig/init
03. Go to end of the file
You will see “PROMPT=yes” it’s change to “PROMPT=no”
04. Save this file
Ctrl + O
05. Exit the file
Ctrl + X
02. Edit this system file
#nano /etc/sysconfig/init
03. Go to end of the file
You will see “PROMPT=yes” it’s change to “PROMPT=no”
04. Save this file
Ctrl + O
05. Exit the file
Ctrl + X
How to change the grub password
01. Login as root
02. create an new encrypted password for grub
#grub-md5-crypt
Password: ****** (uddika)
Encrypted: $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password)
03. copy the new encrypted password by highlighting it using the mouse
04. Open the grub configuration file for editing
#nano /etc/grub.conf
05. Find this line
password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
06. Replace with the following line (Right click the mouse to paste new password)
password --md5 $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password above)
07. Save this file
Ctrl + O
08. Exit the file
Ctrl + X
02. create an new encrypted password for grub
#grub-md5-crypt
Password: ****** (uddika)
Encrypted: $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password)
03. copy the new encrypted password by highlighting it using the mouse
04. Open the grub configuration file for editing
#nano /etc/grub.conf
05. Find this line
password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/
06. Replace with the following line (Right click the mouse to paste new password)
password --md5 $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password above)
07. Save this file
Ctrl + O
08. Exit the file
Ctrl + X
enable user authenication for single user mode
By default you will be automatically logged in to single user mode as root, this can be security risk so better to enable a user login add the single user mode
Note - Debian and therefore Ubuntu both require root password when booting into
single user mode or recovery mode. RHEL and CentOS allows access from the console
into single user mode without a password. This is handy when things get
messed up preventing access to the auth subsystems. To accomplish the
same behavior under Ubuntu, edit the /etc/inittab file and change the line
01. To edit this system file
#nano /etc/inittab
02. Go to a new line at the end of file then type
sum:S:wait:/sbin/sulogin
03. Save this file
Ctrl + O
04. Exit the file
Ctrl + X
Note - Debian and therefore Ubuntu both require root password when booting into
single user mode or recovery mode. RHEL and CentOS allows access from the console
into single user mode without a password. This is handy when things get
messed up preventing access to the auth subsystems. To accomplish the
same behavior under Ubuntu, edit the /etc/inittab file and change the line
01. To edit this system file
#nano /etc/inittab
02. Go to a new line at the end of file then type
sum:S:wait:/sbin/sulogin
03. Save this file
Ctrl + O
04. Exit the file
Ctrl + X
Recovery root password
It happens sometime that you can't remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.
During normal usage, a Linux OS runs under runlevels between 3 and 5 which correspond to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.
01. Start your PC at the boot loader press the space bar before 5 seconds
02. Press “p” and give the boot loader password
03. Press “a” to modify the kernel arguments before booting
04. At the end of the line add the word single or 1grub append> ro root=/dev/lvm/logvol01 rhgb quiet 1
05. It will be logged on as root user
06. Change the root password (As root, changing password does not ask for your old password, therefore running the command :)#passwd
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.
During normal usage, a Linux OS runs under runlevels between 3 and 5 which correspond to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.
01. Start your PC at the boot loader press the space bar before 5 seconds
02. Press “p” and give the boot loader password
03. Press “a” to modify the kernel arguments before booting
04. At the end of the line add the word single or 1grub append> ro root=/dev/lvm/logvol01 rhgb quiet 1
05. It will be logged on as root user
06. Change the root password (As root, changing password does not ask for your old password, therefore running the command :)#passwd
Disable Ctrl+Alt+Del restart
01. Login as root
02. Edit the following system file (inittab)
03. To locate the system file #whereis inittab
04. To find out the file type #file /etc/inittab
05. To edit the text editor #nano /etc/inittab
06. Comment this line#ca::ctrlaltdel:/sbin/shutdown –ts –r now
07. Save this fileCtrl + O
08. Exit the file Ctrl + X
09. Reload the inittab file in to memory again#init q
or otherwise we have to restart the system
02. Edit the following system file (inittab)
03. To locate the system file #whereis inittab
04. To find out the file type #file /etc/inittab
05. To edit the text editor #nano /etc/inittab
06. Comment this line#ca::ctrlaltdel:/sbin/shutdown –ts –r now
07. Save this fileCtrl + O
08. Exit the file Ctrl + X
09. Reload the inittab file in to memory again#init q
or otherwise we have to restart the system
Saturday, 6 February 2010
Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
ERROR 2002: Can’t connect to local MySQL server through socket
‘/var/lib/mysql/mysql.sock’ (2)
ก็เลยลบ mysql.sock ไป จริง ๆ ตรงนี้ไม่น่าจะใช่ปัญหาหลัก
‘/var/lib/mysql/mysql.sock’ (2)
ก็เลยลบ mysql.sock ไป จริง ๆ ตรงนี้ไม่น่าจะใช่ปัญหาหลัก
ปัญหาก็คือตัว my.cnf มันทำ start mysql ไม่ได้
วิธีแก้ก็ เปลี่ยน my.cnf เป็นอะไรก็ได้ เช่น my.cnf.old
หลังจากนั้น start mysql ให้ได้ก่อน แล้วค่อยเปลี่ยนชื่อ my.cnf.old มาเป็น my.cnf แล้ว restart อีกครั้ง
แต่ต้องชัวร์ว่า my.cnf config ไม่ผิืดครับ
วิธีแก้ก็ เปลี่ยน my.cnf เป็นอะไรก็ได้ เช่น my.cnf.old
หลังจากนั้น start mysql ให้ได้ก่อน แล้วค่อยเปลี่ยนชื่อ my.cnf.old มาเป็น my.cnf แล้ว restart อีกครั้ง
แต่ต้องชัวร์ว่า my.cnf config ไม่ผิืดครับ
Subscribe to:
Posts (Atom)