Basics of User Management
A comprehensive guide for basic user management of a linux box:
Continue reading ‘Basics of User Management’ »
Archive for the ‘Basics’ Category.
A comprehensive guide for basic user management of a linux box:
Continue reading ‘Basics of User Management’ »
Let us see how to use find command to gain lots of useful information about users and their files.
make a file with your favorite text editor. Name this file “old” and place the word “day” within it. Save it in your home directory. /home/<username>.
Now in a shell run:
sed s/day/night/ old >new
Now you will have a file called “new”. Open that file and it should have changed the word day to night.
Re-edit the file “old” and make it look like this:
day day day
day
day
Save the file.
This time we’ll run a similar command
sed s/day/night/ old>new.2
When viewing the file new.2 you will see this:
night day day day
night
night
You will notice only the first field in each line got changed. Most Unix utilties work on files, reading a line at a time. Sed, by default, is the same way. If you tell it to change a word, it will only change the first occurrence of the word on a line. You may want to make the change on every word on the line instead of the first.
sed s/day/night/g old>new.3
Now if you view the new.3 file, every instance of day should have turned to night:
$ cat new.3
night night night night
night
night
The ‘g’ option tells sed to run globally and not for the first instance within each line.
This is my very over simplified take on sed. Please see the link above and the sed man page for more. Feel free to talk about it
For a more advanced look at Sed please see here: http://www.grymoire.com/Unix/Sed.html
While the Linux find command has a number of uses, the most obvious being looking for files matching full or partial names, the one often underused option is to use it to locate old files. To show all files in a directory older than 14 days:
find /var/crap_files/* -mtime +14 -print
An even more powerful option is to use the -exec switch which allows you to delete old files. To delete all files in /var/crap_files/ older than 7 days:
find /var/crap_files/* -mtime +14 -exec /bin/rm -rf {} \; 2>/dev/null 1>&2
Recently added to the site: Linux: Rute User’s Tutorial and Exposition (you’ll notice another link to it on the right hand column beneath the sections).
This is a great Linux reference covering a great deal of the basics, available for legal electronic distribution. Enjoy.
sed 's/fubar/foobar' filename sed: command garbled: s/fubar/foobar
gsed 's/fubar/foobar' filename gsed: Unterminated `s' command
So, if you’re having problems getting sed syntax correct, switch to gsed for a while.
In almost all Linux distributions the Linux log files are stored in ‘/var/log‘ directory.
A common way to watch log files is to use the -f flag and tail. Most log files are protected so you will need elevated privileges to view them.
Show the last few logins and display new ones as they are authenticated. Ctrl + C to quit.
Running numerous jobs via the cron daemon on a daily, even hourly, basis can lead to a lot of mail notifications. I run many jobs whose output I do not really need to be informed of (for example, the overnight stats run on some of my web servers; I am in the habit of checking stats daily and if the job failed I would know), so how do I go about preventing crond telling me about these jobs?
PAM (Pluggable Authentication Modules) is one of those dark corners of Linux where most users don’t venture – in fact, I’d be willing to bet that the majority of Linux users don’t even know what it is. And yet, PAM is at the heart of every single thing in Linux to do with authentication.
Take our guided tour of PAM, join our science lab and perform our experiments (no bunsen burner necessary!) and see how PAM gives you fine-grain control over your security policy.
You may know that if you type
sudo [command]
Your password will be asked, but if you type it again in a few seconds, it will not be asked, because Linux “remember” your password for some time, well if you are really concerned about this, you may force Linux to “forget” your password inmediately.
How to do it?
sudo visudo
And add this line:
Defaults timestamp_timeout = 0
You may change 0 to any number representing the minutes you may want your password to be “remembered”, or let in 0 so you will need to type your password each time you type sudo