Linux

Tips for Linux Users

Rescued with Linux !!

Ever been caught without that rescue disk, thinking that everything was lost? Well, then, it's tomsrtbt to the rescue! Works with Linux and Windows, too! Read more here.

Last weekend, the auto-update on Windows XP completely corrupted the OS and the box went into a frenzy reboot cycle. There was no way to boot up in windows, even with a boot/rescue disk. I used "MandrakeMove", a complete OS on a single CD. This automatically recognized the Windows OS and mounted it to "/mnt/windows" and also recognized my external Iomega CD Writer. From this point on, I backed up everything from the home directory on Win OS, formatted and installed Linux...

Keeping Fedora upto date with Yum !

Written by Rick Nicholas

Yum is an automatic updater and package management tool for rpm based systems. Yum automatically computes dependencies and figures out what steps need to occur in order to install packages. It makes it much easier to maintain groups of machines without having to manually update each one using rpm.

Yum can be used in place of, or in addition to the Red Hat up2date and rpm tools which also come with Fedora Core 1. My personal preference is to use Yum as a complete replacement for both tools as it has proven to be faster, more reliable, and also offers functionality not available when using the other tools such as;


  • Multiple Repositories

  • Simple Configuration File

  • Correct Dependency Calculation

  • rpm-consistant behavior

  • comps.xml group support, including multiple repository groups

  • Simple interface

Yum can not only be used to keep packages already installed on your system updated, but can also be used to install packages directly, which is awesome on those days when you can't find a cd to save your life. Yes, you could always download the sourceball, or go looking for an rpm on the net, but this is soooo much simpler. Yum is developed and maintained through the hard work of the folks at Duke University and is made available to the rest of us under the GNU GPL. So now you know a little about Yum, lets check out what it can do for you !

Learning Linux: Command Line Interface Series

Great CLI for noobies tutorials to help you get started with using Linux.

Scheduling in Linux

How many of us dread waking up at 3am just to run some backup program on our Linux systems? Or maybe send a message to ourselves to remind us of our appointment later on in the evening. Linux comes equipped with scheduling tools. Tools that will let you get a full night's rest and still have that backup program automatically run at 3am on the dot, and even send us an email letting us know about any appointments. In this NHF, I will be discussing the at and cron scheduling utilities.

Using the at utility

The at command is used for jobs that need to be run only once. at is an interactive program and it takes in an argument, which is the time and date that you want the job to be run. All outputs of at are sent by email. So let's say it's 1pm, and we have a meeting at 3pm. In order to be reminded of this meeting at 2:30pm, we can type:

at 2:30pm
at> echo "Are you ready for your meeting???"
at> ctrl-d 

We need to hit the combination ctrl-d in order to signify that we're done with what we want run. So now at 2:30pm you will recieve an email with the words "Are you ready for your meeting???' in it. Great right? Now one thing you should understand, is that at is very flexible about the time you specify. Let's say you're someone who's lived in the military all your life and you tell time military style. So you want to remove all evidence of a top secret file at 1600 hours. Then you would type:

at 1600
at> rm -rf /top-secret
at> echo "Top secret files deleted"
at> ctrl-d 

At 1600 hours, the directory and everything in it will be deleted. However, when this happens, you will not receive any emails unless there is any output from running the command. So we also have at to send us an email telling us that the files have been deleted. So now you're probably wondering, what more can at do? Well for those of us who happen to be too lazy to type numbers, we can type stuff like:

at midnight
at> mail foo@bar.com -s "Where is my money?" < email.txt
at> ctrl-d 

This executes the job at midnight. We can also change that to noon or teatime (which is 4pm by the way). How about being a little more specific? Let's say you need to add your IP to the /etc/hosts.allow file so you can log in at 3pm 10 days from now:

at 3pm + 10 days
at> echo "ALL: 123.456.78.9 >> /etc/hosts.allow"
at> ctrl-d

For the final example, let's say that you don't know what time it is right now, but you know that you need to call your boss up at about 40 minutes. Now you could easily lose track of time so you decide to remind yourself:

at now + 35 minutes
at> echo "Call your boss"
at> ctrl-d 

So now you will get an email 5 minutes before you need to call your boss. Easy right? Keep in mind that you can run any number of commands you want with at until you enter the ctrl-d combination.

Additional at utilities

It's all good and well that you can now schedule Linux to do stuff for you. But what if you want to see what jobs are waiting to be executed, or if you want to remove a job from being executed? In order to list the current jobs that are waiting to be executed, you use the atq command. atq will list the job number as well as the time when the job is scheduled to be executed. To remove a job from being executed, you type atrm followed by the job number. Now every job has a number, and this number can be seen from the atq command. Let's take a look:

atq
20 2000-03-14 15:41 a
21 2000-03-12 16:11 a
22 2000-03-13 00:00 a

So here I see that I have three jobs waiting to be executed. Let's say I decide to remove job 21. To do so I would type:

atrm 21 

That's it. To confirm this, run atq again and the job will no longer be there.

Using cron

cron, like at is used to run a program at a scheduled time. The difference is that cron is designed for jobs that need to be executed more than once. Let's say, you need to have a program run every day at 3pm. You can't do this with at. at runs the program only once and then it won't run it again unless you tell it to. cron unfortunately can be a little confusing to newbies, but once you learn it, it'll be a great help. In order to schedule commands using cron, we use the crontab command. Let's get into it right away. Let's say you want to recieve an email every minute with the words "Hello World" on it. First, type:

crontab -e 

The -e flag lets you edit your current cron table. You probably don't have anything in there yet, so type the following:

* * * * * /bin/echo Hello World 

What does that mean you say? Well, the first five asteriks specify the minutes, the hour, the day of month, the month, and finally, the day of the week. Now the first field ranges from 0 to 59, the second from 0 to 23, the third from 1 to 31, the fourth from 1 to 12 (or a name such as jan, feb, mar, etc...), and the last from 0 to 6 (or a name such as mon, tue, wed, etc...). The field that says /bin/echo Hello World is the command field. This is where you specify what command to run at the specified time and date. So to run this command at 2:30pm every Monday we would type:

30 14 * * mon /bin/echo Hello World 

The first entry specifies 30 minutes after the hour. The second entry specifies running at 1400 hours or, 2pm. The second two entries are asteriks which means every day of the month, of every month. And finally, the last entry which specifies mon (Monday) states that we run the program every Monday only. Now if we wanted to have this run every day, we would change the field mon to an asteriks. How about a couple more examples to get you used to it:

0 2 * * * /bin/echo Hello World 

What this does is runs the command on the dot of 2am every day and month. The next command will run at 5:21am, on July the 1st:

21 5 1 jul * /bin/echo Hello World 

Once the program finishes running, it will wait until the next July 1st to run again. So as you can see, cron is a very flexible and very powerful program. It's important to be able to learn how to use it. Now let's try for something a little more complicated. Suppose you want the command to run on the dot of 3pm, 6pm and 11pm every day? We can use a command to separate the hours in the hour field (or any field for that matter):

0 15,18,23 * * * /bin/echo Hello World 

Don't leave any spaces after the commas. Here's another example of the above that runs only on Mondays and Wednesdays:

0 15,18,23 * * mon,wed /bin/echo Hello World 

Okay, that's all good, but there's a little bit more. You can also have it such that cron runs a command from a specific time to another specific time. So let's say we want to run the command from Monday to Thursday. We would do:

0 3-5 * * mon-thu /bin/echo Hello World 

What this does is runs the command on Monday through Thursday from 3am through 5am daily. So now you can run any command at any time you want.

Additional flags for crontab

Additionally, crontab takes the -l flag. When run in this manner, crontab will show you your current cron table and what's scheduled to run and when. If you are running as the root user, you can also use the -u flag followed by a user name to edit that user's cron table or just to list it's contents.

Restricting scheduling

If you run a system that hosts multiple users, you might want to discourage them from using cron or at for whatever reasons. This can be done. To restrict people from using cron, create a file called /etc/cron.deny and put the name of the user you want to restrict in there. To restrict people from using at, create a file called /etc/at.deny, and put the name of the user you want to restrict in there. Be careful about restricting default system users like nobody. These accounts sometimes run their own jobs at specific times.

Conclusion

That's it. That's all you need to know about scheduling in order to make Linux more efficient and easier for you to use. Be sure to master how these commands work. Sometimes it's the only way to get work done. You can configure cron to backup your system, or to check the integrity of your filesystem and email you the results, anything.

SSH Tunneling

OpenSSH has the ability to create a tunnel to encapsulate another protocol in an encrypted session.

The following command tells ssh to create a tunnel for telnet:

% ssh -2 -N -f -L 5023:localhost:23 user@foo.example.com

The ssh command is used with the following options:

-2

Forces ssh to use version 2 of the protocol. (Do not use if you are working with older SSH servers)

-N

Indicates no command, or tunnel only. If omitted, ssh would initiate a normal session.

-f

Forces ssh to run in the background.

-L

Indicates a local tunnel in localport:remotehost:remoteport fashion.

user@foo.example.com

The remote SSH server.

grsecurity

grsecurity - is a complete security system for Linux 2.4 that implements a detection/prevention/containment strategy. It prevents most forms of address space modification, confines programs via its Role-Based Access Control system, hardens syscalls, provides full-featured auditing, and implements many of the OpenBSD randomness features. It was written for performance, ease of-use, and security. The RBAC system has an intelligent learning mode that can generate least privilege policies for the entire system with no configuration. All of grsecurity su

Having a Bash with Linux Shell

Bashing About

Any Linux administrator who wishes to remain sane relies heavily on scripting to automate routine tasks, customize jobs, and build the plumbing that connects the different utilities that make a Linux system run smoothly. The Linux world is chock-full of scripting languages: Perl, Python, PHP, Scheme, Tcl, Tk, Ruby, Forth, Smalltalk, Eiffel, and doubtless many more. To get the column started, we'll look at shell scripting with Bash, and scripting with Python and Perl.



Understanding what Bash does is fundamental to using Linux. Bash is a command interpreter, the direct interface between you and your Linux system. Python is easy-to-learn, yet capable of handling any system administration chore. Perl is endlessly flexible, which makes learning it rather vexing at times. But it can do almost anything: Complex programs are written in Perl, such as the indispensible game Frozen-Bubble.

Knoppix: Run Linux without installing

KNOPPIX is a compilation of GNU/Linux software, run completely from a CD. It automatically recognizes and supports many types of graphic cards, sound cards, SCSI devices and other peripheral devices. KNOPPIX can be adapted and used as a Linux demo, a training course CD, a rescue system or as a platform for commercial software product demos. It is not necessary to install anything on fixed disk.

MandrakeMove : move with Internet, Office & Multimedia in your pocket!

MandrakeSoft has created MandrakeMove -- a new product based on Mandrake Linux 9.2 that provides a complete personal desktop operating system on a bootable CD. Personal data and configuration settings may be stored on a dedicated USB Key.

MandrakeMove lets you bring your Mandrake Linux system wherever you go, all on a single disc, so that you can connect to the Internet, create & edit Office documents, listen to music, watch movies, and just about anything you can imagine from wherever you happen to be!

With MandrakeMove, there's no need to install a Linux system to have a full-featured desktop: just place MandrakeMove live CD into a CD-ROM drive, boot from the disc, then watch an entire Mandrake system run "on the fly" from the CD-ROM. As a unique added feature, the MandrakeMove CD-ROM may be ejected to access content from another CD.

Getting a colored shell prompt

Working in the world of the Linux command line is normally a monochromatic experience. Carefully chosen colors in interfaces can enhance their useability.

Find out how to color your command prompt !

Syndicate content
Comment