Useful Linux tips and how to edit the /etc/sudoers file without error.
Posted: May 9, 2012. At: 11:40 AM. This was 4 years ago. Post ID: 3759
The magic SysRQ key combination is used to reset the Linux system if nothing else will work. To use this key combination, press: Alt+SysRQ then tap these keys in order: R, S, E, I, U, B. This will perform a safe re-boot of your Linux system assuming the Magic SysRQ keys are enabled in your Linux kernel.
Using the VIM editor is simple in the command mode. Use the e key to enter editing mode. Delete a line in command mode with the dd command, and the dw command will delete a word. The Esc key will exit all modes back to the command mode. To search a file for a certain string, the / key will enable a search mode. To save a file you are finished editing, use the :w command. The :q command will quit. You may combine commands like this :wq to save and quit in one go.
The / key will also work in the Firefox editor to allow quick searching of a web page.
To perform a safe reboot of your computer from the command-line use the reboot command. To shutdown your computer use the shutdown -h now command. Modern Linux distributions support suspend and resume, the sudo pm-suspend command will put your computer to sleep.
This is what my /etc/sudoers file looks like. I have added the line: gordon localhost = NOPASSWD: /usr/bin/apt-get to this file allowing my user gordon to access the /usr/bin/apt-get command without requiring the entry of my password. Therefore if I type sudo apt-get update for example I will not be prompted for my password. The sudoers file MUST always be edited with the sudo visudo command. This will copy the /etc/sudoers file to the /etc/sudoers.tmp file and when you are done editing it will check the file for errors and if it looks OK it will then commit the changes back to the /etc/sudoers file. This is to ensure that you are not locked out of your system if you make a typo whilst editing the file. You must still be careful when editing this file though. The man sudoers command will provide a lot of information on how to edit this file properly.
# User alias specification # Cmnd alias specification # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL gordon localhost = NOPASSWD: /usr/bin/apt-get #includedir /etc/sudoers.d