If you are a Linux user, particularly Ubuntu, and are the only person that uses your computer, sometimes the fact that your operating system constantly requires for your password every time you log in, then at a certain moment you might want to decide to get rid of it. All you need to do is to follow the next steps carefully and you will be ready to go.
Run a new terminal. This is essential, since, as you already know, every important command and feature of Ubuntu and Linux in general must be done in this way
Run the command ‘sudo visudo’. This will at first require the current root password, as every line starting with ‘sudo’ does.
Type the root password and hit return
A new document will now open in your terminal, which will require some editing. Specifically, a new line should be added in the end of this document. This line is ‘username ALL=NOPASSWORD:ALL’. As you can guess, this will make your operating system stop asking about your root password every time you log in, regardless of the user you use for this process.
Save the edited document and make sure the changes are active.
Restart your computer and check to see whether you can log in without your root password.
As you can see, getting rid of the root password is a rather easy process and sometimes it will save you a lot of time. However, make sure you only do this if you are the only person who uses your account on your operating system, because otherwise your security will be exposed.
This password removal tweak will also work for ‘sudo’ commands as well, making it even simpler for you as a Linux user.
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 2 and 5 which corresponds 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.
Some Linux distribution, such as Ubuntu for instance, offer a specific boot menu entry where it is stated “Recovery Mode” or “Single-User Mode“. If this is your case, selecting this menu entry will boot your machine into single user mode, you can carry on with the next part. If not, you might want to read this part.
Using GRUB, you can manually edit the proposed menu entry at boot time. To do so, when GRUB is presenting the menu list (you might need to press ESC first), follow those instructions:
- use the arrows to select the boot entry you want to modify.
- press e to edit the entry
- use the arrows to go to kernel line
- press e to edit this entry
- at the end of the line add the word: single
- press ESC to go back to the parent menu
- press b to boot this kernel
The kernel should be booting as usual (except for the graphical splash screen you might be used to), and you will finally get a root prompt (sh#).
Here we are, we have gained root access to the filesystem, let’s finally change the password.
As root, changing password does not ask for your old password, therefore running the command:
will prompt you for your new password and will ask you to confirm it to make sure there is no typo.
That’s it, you can now reboot your box and gain root access again.
Many Linux users use the ‘find’ utility when searching for files using the command line on their system. They’ll do a simple: find / -name ‘pattern’
Really though, the power of find isn’t just in finding names of files but rather specific details about those files. For example, if you wanted to find files which are writable by both their owner and their group: find / -perm -444 -perm /222 ! -perm /111
or perhaps find any file that’s been altered in your Download directory in the past 24 hours: find /home/user/Downloads/ -mtime 0
As you can see, the find command is very versatile and can be used to find an array of different attributes of files. There are times though where I’m just looking for something and I don’t want to have to wait for the command to scan the entire directory tree in order to track it down. That’s where locate comes in with quick and simple results.
Using the locate command can only be accomplished if you install the mlocate package. Most major distributions have this available. If not, head over to the mlocate homepage and install manually. Once that is accomplished, you’ll need to manually run a command to index your filesystem with it…otherwise, you’ll have to wait for the command to run automatically as it registers with cron to do so on a system level. Open a terminal and change to your root user, then execute the following: updatedb &
This updates the mlocate database that indexes your files and forks it to the background (the ‘&’ forks it to the background). You can now logout of the terminal as root and the process will quietly work in the background.
After the command completes, using mlocate is as easy as using the locate command: locate firefox | less
The command above will look for all files with Firefox in the name and pipe the command through less so you can use the space bar or enter key to scroll the file buffer. Of course, the reason we pipe it through less is because any file that resides in the ‘firefox’ directory will be reported in the output. While this tool isn’t as granular as the find command, it is a quick way to track down paths, directories, and files you know should exist. Since the data is indexed using the updatedb command (by cron) the results are very quick and the command does not have to scan through the filesystem to return the results.
There are plenty more advanced options via flags (such as following symbolic links, making search term case-sensitive, and even using regexp). See the man page for details on how each of these options work. Play around with locate and see what you can do! It’s a powerful and quick search command!