There comes a time when you want to execute a command with root privileges but you don’t want to enter root password again and again. May be you want to allow a user to be able to execute one particular command but can’t share root password or some command needs to be executed on boot but requires root..sounds familiar? Keep reading.
The kind of approach we will be using is very often frowned upon. Mainly because it beats the purpose of sudo i.e. allowing only privileged users to execute certain commands. It is also looked upon as security breach, but you are fine if you know what you are doing.
You can run sudo command without password on linux by modifying /etc/sudoers file which maintains – which user can execute what. Before editing this file, lets take a backup – just in case – it gets messed up.
/etc/sudoers file can be edited in any editor of your choice but it is highly recommended to use visudo command. If there is a syntax error in sudoers file then you will be locked out of shell and we don’t want that. While visudo command checks for correct syntax and restricts user from saving a corrupt sudoers file. Enter following command to edit sudoers file:
For example, if we want user “ayush” to be able to execute, say, “visudo” without asking for password then we will have to append following line in sudoers file in the end.
ayush ALL = NOPASSWD: /usr/sbin/visudo
This needs to be added at the very last of sudoers file because if there are matching entries then last line will override all previous occurrences.
This is how my sudoers looks after editing:
Now, user “ayush” won’t be prompted to enter password while executing “sudo visudo”.
You can replace your own username and command(s) you want to execute without entering root password:
[username] ALL = NOPASSWD: [command]
This can be extended for multiple commands by comma separating them.
You may be struggling with the recent switch to Ubuntu 14.04 or simple Unity is not what you expected it to be. Not having a taskbar to put minimized windows is what I missed the most when I made the switch. And, I know I am not the only one. So, here we will go through steps for how to install a taskbar in Ubuntu 14.04.
Tint2 is the tool we will be installing which brings back a feel of taskbar to Ubuntu 14.04. After installing, we will add it in “startup applications” so that you don’t have to start it by yourself everytime you boot.
Launch your terminal by pressing Ctrl + Alt + T or whichever way you like. Type in following command and hit “Enter”.
Enter your password when prompted.
After displaying installation progress, you will be prompted “Do you want to continue? [Y/n] ” press “y” and hit “Enter”.
You have successfully installed tint2. Now we need to add it to startup applications.
Click “Search” button, first one on Unity bar OR hit “Super” key (the one with Windows sign on a Windows machine).
Start typing “Startup app” in search area, items matching the search query will display below the search area. When “Startup Applications” tool is there, click to open it.
On “Startup Applications Preferences” window click “Add” to add our application (here tint2) to startup applications.
In “Add Startup Dialog” enter name of application of your choice (here “Taskbar”), enter command precisely “tint2” and enter comment of your choice (here “My Taskbar”). Click “Add”.
Now you can close the “Startup Applications Preferences” window.
Please Logout and Login again for changes to take effect. Restart is not required.
I don’t have to brag on wonderfulness of Linux. As the use of Linux based operating systems in industry is increasing exponentially that it has definitely become a ‘need’ for the IT personnel now. Market needs Linux experts much more than they actually exist. Talking of statistics, growth of demand for good Linux developers is at 31 percent!
Those who want to encash the opportunity, can choose to start learning Linux with few websites which are considered best at what they are doing. Following is the list of such websites:
PaulPaulito has not been there for a long time but looks promising so far. This Netherlands based website is offering training videos in English as well as Spanish and German. The organization running this website is a Linux Professional Institute (LPI) approved training partner. The courses are designed in a way that they help in preparation of LPI certification Exams. It also offers practice exams. This website is not free, costs about 67 USD per month.
LPI is a certification organization has its training partners all over the world. The site of LPI itself can be used to look up a training partner around your location.
Red Hat has its own training and certification programmes. Most of the courses offered by Red hat are targeted at Red Hat Enterprise Linux, being a Linux vendor has its own advantages. Online courses consists of Red Hat System Administration and Red Hat Linux Troubleshooting, fees starts from $1400.
BeginLinux.com provides a variety of courses mainly focused on CentOS Server, Ubuntu Server and Apache Security. Plans start from 95.95$.
Variety of online training courses are provided by The Linux Foundation. Classroom programmes are also available. Embedded Linux, the Linux Kernel, Open source Compliance are some courses to name a few of all that are included in offered courses. Advanced tools are used in delivering the course such as live Java-based virtual collaboration and Live audio conference bridge. You can use their search tool to find the course which can fit your need. Prices starting from $2750.
If you are interested in learning with Ubuntu, Canonical can serve you with huge number of courses listed in their training section.
IBM has its own set of Linux courses. The price for its Linux training classes start at $675.
LinuxCertified is known to provide onsite training facilities along with distance learning options. You can opt for this at $99.
Novell provides free training with no registration overhead. The courses are training modules which help in better understanding of their product just like canonical and IBM.
A wide range of Linux Tutorials are available with The Virtual Training Company. Some content is kept free as well. The tutorials provided are either in Flash or QuickTime format. A user can get a chance to browse though 900 course on the site with a price tag of $30 on it.
These are the few sources which know what they are doing, there exist a lot more than these. We at LinuxStall also try to help you in getting comfortable with Linux. If you wish to add more sources to this list, we have our comment section open.
We all must have heard about defragmenting our hard drives to speed up performance. Sound of that similar to windows users but we don’t have any defragment utility, hell, we don’t need to defragment! And why is that? Lets find out-
I remember when I was new to Linux, a friend of mine came with a hard disk and asked me to defragment it (yeah, we all have faced it). It was easy in windows, how hard it could be in Linux? I connected the spare bus to his hard disk and then started a mission to defragment via Linux. I can’t stress this enough that I was new to Linux and didn’t know much about how things work. After trying every bit I knew, looked up the mighty google and it came like a bolt from the blue- NO DEFRAGMENTATION NEEDED IN LINUX. </chitchat>
I’ll cover it in as short as possible; your hard disk is divided into sectors. These sectors are capable of storing small pieces of data. So, when the size of file is more than size of a sector then the file is saved over multiple sectors, as simple as that. As the new file comes, it is saved next to previous sector. But, when the size of first file increases, it might not find free sectors near original file so it will be saved few sectors apart, this goes on and on. While reading this file, the head will have to skip physical locations which ultimately will make things slower. Defragmentation is the process in which file is put back in continuous fashion so that there is no skipping of sectors.
Note: Defragmenting is not recommended for SSD drives. They have a different theory, doing so will reduce their life.
Linux’s file systems deal with fragmentation in an intelligent way. Instead of placing files next to each other, it keeps a lot of space between the sectors of two files therefore leaving space for these files to grow. This keeps fragmentation far away, yet not impossible. Even if there are fragments, file system attempts to move the files thereby reducing the fragmentation. The system is designed to avoid fragmentation in normal use. You might face some fragmentation when your space fills up, may be 80% or 90%. The more suitable method to deal with it is to get a new hard drive with more space else you can copy your files to other drive, delete original files and then copy them back- they will be arranged automatically.
First advantage over Windows which every one claims is, Linux is free from virus so it doesn’t need any antivirus…WRONG!
Don’t live in a ‘fool’s paradise’, they also have Linux in their sights!
Only problem is, there are so many distros, they don’t know where to start…lol!
Jokes apart, Linux antivirus products do exist, its just that the number is far too low when compared to those of Windows. Have a look at few major reasons behind this:
It would not be correct to say Linux machines are never infected; they are vulnerable to “rootkit”. Rootkits allow attacker to get top level access to victim’s machine and have full control and during attack user is never alerted about this. Rootkit can spy or modify data and even run applications in background. Some other threats to Linux machines are poisoned DNS entries, spam gateways, backdoor botnets, etc.
You can have a look over the list of viruses here:
Vastness of open source can leave anyone in confusion. Whether it is distro hunting or phrases that are used to explain related concepts. The one which annoys every single beginner is that Open source is said to distribute free software, so far so good, but what exactly we mean by free? Free as is Beer or Free as in Speech? Keep reading.
The difference can be narrowed down to “no money” versus “no restrictions (or a bit of them)”. In English, free is often mistaken for both the meanings but in Spanish they have different words for them, Gratis and Libre.
Java from Oracle is a product which is free as in beer. When you are offered a beer, you are not supposed to pay for it but enjoy. The ‘body’ giving away pays for it and everyone enjoys it at no cost.
Java from Oracle is available free of cost for everyone but restricts users from getting even a glimpse of source code. Hence, users are also deprived of the liberty of modifying the code. Speaking of that, none of distributing publicly and submitting bug fixes is available. The decision of What/When/How you get the “beer” is made by the “giver”.
In addition to facility of getting the software for free, the air of liberty comes in. The liberty in “libre” is more than you get in “gratis”. Following are the rights you have in software which are Free as in Speech:
♦ You can use it anyway you want. They don’t care if the software was made for computer you are running it on mobile device. More the merrier!
♦ You can easily see the internal working of the software. Users want to know the secret ingredients in their favourite beer but are deprived of this pleasure in case of free beer.
♦ Sharing is caring! After using and falling in love with the software, one would definitely want to share it and libre allows him to do that without violating any law. Distribute it publicly whether by packaging it with your software or provide a mirror, etc.
♦ You can be a part of the development process. If you find a bug and a fix to it, you can submit it so that community benefits from it. After all it is all about giving away.
CentOS and Ubuntu both are Linux distros. Below are some major differences between them.
1. CentOS is based on RHEL (Red Hat Enterprise Linux), while Ubuntu has its roots in Debian.
2. On an Ubuntu system the root password is randomly generated which is not known to the administrator. You will have to use ‘sudo command’ to get root-privileges.
3. Repositories of Ubuntu contain fresher packages than CentOS, it tends to be less conservative than CentOS, whereas CentOS packages focuses only on security patches.
4. CentOS uses YUM package manager with RPM packages whereas Ubuntu uses apt with DEB packages.
5. Ubuntu cleanly upgrades between major versions, CentOS is not so good to do that (needs a reinstall often). [via: Liz Quilty]
Know some more differences? Please put them in the comment box, I will add them in the post.
Recommended reading: “CentOS vs Ubuntu“
sudo command is required when executing a command with some other user’s permission. Other user can either be root or else. Why we need to execute command with root’s permission? There are some commands that do some change in the system which are dangerous and can bring the system down, only root has such permissions.
WITH GREAT POWER COMES GREAT RESPONSIBILITY!
One can also switch user via su command and then execute the desired command but sudo is much more secure than su. Commands (along with arguments) executed with sudo are logged in a file. For Red Hat distros, /var/log/secure saves all the logs and for debian based, its /var/log/auth.log.
The file /etc/sudoers can be edited for configuring sudo and giving privileges to individual users or group of users.
For an individual user
Syntax for allowing an individual user (here Ayush) is:
ayush ALL=(ALL) ALL
“ayush” here is username of the user you want to allow
“ALL” specifies that sudo is accessible from all terminals
“(ALL)” specifies all users
“ALL” for all commands
For a group
Entry in sudoers file goes like:
%linuxstall ALL=(ALL) ALL
“linuxstall” can be replaced by the name of group.
Once the sudoers file is all set, you can now execute commands as root. For an instance, mount command can only be executed by root, but things go well with sudo.
There are some files that only root can save (say /etc/group) but having sudo in hand, it can be done as follows:
But, if you have opened the file as a normal user and wish to save but unable as only root can do that- sudo is your friend:
:w !sudo tee %
Above command will the save the file for you as a root even when you didn’t use it while opening. sudo just doesn’t mind!
If a user is not listed in sudoers file and tries to use sudo, admin will be notified by making a log entry and user will get following error:
<user> is not in the sudoers file. This incident will be reported.
When it comes to operating systems, Unix is the mother of operating systems. Members of rich Unix family are:
Mostly, Linux is considered to be a copy of UNIX. Lets hear the actual story now. Linux was actually a late addition to the family. It was written by Linus Torvalds back in 1991 and it was meant for IBM computers. As a matter of fact, in the world of operating systems, Linux has come up as a great operating system and it is welcomed with huge popularity. Commercial enterprise servers are running on Linux. Another cherry on the cake, Laptop and PC companies are also providing GNU Linux as a pre-installed OS on their systems so that individual users can also get a bite of it.
An extensive brain storming confusion is if Linux a kernel or Operating System. After some time, people just start ignoring this doubt as it never gets answered, well keep reading for the solution. What Linus Torvalds wrote was Linux kernel and it had a lot of features similar to UNIX one. Why it is confused with OS, actually commercially available distributions that provide graphical interface, compilers and other utilities along with Linux kernel are referred to as Linux Operating System.
Linux is, as they say, a UNIX-like kernel, because it has ‘some’ common features but still there are areas where they are not same. Difference between Unix and Linux can be understood by going through following points.
1. The difference in approach: There is a class of kernels that fall in Monolithic category, Monolithic ones are those which operate in one and only one process, they don’t have any other process for any kind of task. Another category is called Micro-kernel where core of the kernel is assigned one process while other processes are there for its side tasks like drivers, etc. Linux lies within Monolithic category with few exceptions in Micro-kernel.
2. Loadable kernel Modules: Unix systems are bound to have static links of new modules to be added or recently added. Linux differs here too, it supports new additions on the fly. For example, drivers can be loaded dynamically whenever they are needed. This feature is recognized as Loadable kernel Modules (LKM). This feature enables us to add any component dynamically without arising the need of compiling the whole kernel again. Unloading can also be performed in similar fashion. This adds to the flexibility of Linux.
3. Kernel threads: Kernel thread is an independent execution flow. It can be used to execute some user process or any kernel code. Most of the UNIX-like systems constitute kernel thread sets. Threads always operate in same address space, so it is not expensive to perform context switching on kernel threads in comparison to processes- this explains why Unix-like systems have kernel threads. Kernel threads are used, on linux, to execute kernel code.
4. Multi-threading: Multi-threaded applications are those which create multiple execution flows. These flows are also known as threads and are light weight processes. Nowadays all operating systems have support for multi-threading. Most of the UNIX-like operating systems LWP (read light weight process) are kernel thread based, while on the other hand Linux handles them a bit differently. In linux, LWP are created by calling the clone() function which leads to creation of separate processes. Same task can also be carried out with fork() function but clone() lets recently created processes share their memory, address space etc. Their working in shared environment gave them a name “threads”. Hence, multi-threading is supported by both of them but they differ in internal handling of it.
5. Preemption and non-preemption: We have a category of kernels which are able to pre-empt currently executing process and hence we call the preemptive kernels. Processes are run on a priority basis. If currently executing process is a low-priority one and a high-priority one process comes up, it can interrupt the current process and start executing itself. Non-preemptive kernels are those which don’t forcibly interrupt the current process even if a high-priority process has to wait. Linux based operating systems are non-preemptive while UNIX systems are fully preemptive. Linux based Realtime operating systems are found to be fully-preemptive.
Bottom line, despite taking the basic idea from UNIX it still differs in some aspects because it has inherited a lot from it and will always be considered a part of Unix family.
Ubuntu users are used to using Synaptic for their software needs and the other user chunk has apt-get via command line. But Ubuntu users don’t have to be sad for those packages which are still distributed in RPM format. Installation of RPM packages can be checked here.
If an Ubuntu user wishes to install a RPM package, a utility is created for this purpose and is called Alien. This doesn’t guarantees that the package will work, its actually a software that converts format of the package. In order to install Alien some prerequisite software are also required including gcc and make.
To install Alien utility, following code should be executed:
sudo apt-get install alien dpkg-dev debhelper build-essential
For performing conversion, run the following command:
sudo alien SomePackage.rpm
To continue with the installation, dpkg tool can be used as follows.
sudo dpkg -i SomePackage.deb