Fedora Linux by Chris Tyler
Now that I’m moving onto some of the more advanced Linux features and ones that rely upon the GUI, the library-borrowed books I’ve been using are becoming less and less useful. It is not that they are bad books, just that they are old editions. So on Friday I had a trip to London’s excellent Foyles bookshop. It has, by a large margin, the biggest, most comprehensive IT section I’ve ever come across. I am a fan of O’Reilly IT books and they seem to stock absolutely everything O’Reilly has in print.
My choice of book was Fedora Linux by Chris Tyler, published in late 2006 by O’Reilly. I choice it because it covers SELinux and Virtualisation, and more generally seems to explain each topic in a comprehensible way. It’s over 600 pages long, so pretty comprehensive, too.
Filed under: Books | Leave a Comment
I’ve never been a fan of when computers insist on having the operating system CD inserted when they ought to be able to get whatever they need from the internet. Fedora would sometimes ask for the CD when using the Add/Remove Software (package manager) feature. Fortunately, it’s easy to stop that happening: simply delete the repository called InstallMedia (which can be found in in the Edit menu –> Repositories window in the package manager.)
Filed under: Fedora 8 | Leave a Comment
At and batch
While cron is used to schedule regular tasks, the at and batch commands are used to schedule one-off tasks at some point in the future. The difference between at and batch is that at does a task at a given time in the future, while batch does the task when the system is not doing very much, specifically when the “load average” drops below 0.8.
To set up at instructions, type at followed by a time at the command line, as in:
at 13:00
or
at now + 1 hour
To set up batch instructions, simply type:
batch
With both of these, enter your commands, line after line until finished, and then press Ctrl-D while on a blank line. Type the following to get a list of commands set to be completed in the future:
atq
The files /etc/at.allow and /etc/at.deny are used to restrict access to both at and batch.
Filed under: Processes | Leave a Comment
Cron is the method of getting Linux to repeatedly do a task at regular intervals. For example, it can automatically produce a backup in the middle of the night or save some status information to a log file. It can send an email reminding people to file their TPS reports every Friday at 2pm.
The key file related to cron is /etc/crontab, and this file along with the /etc/cron.d/ and /var/spool/cron directories, are checked each minute; the crond daemon reads them and decides if there is anything to do.
Ordinary (non-root) users have their cron files stored as /var/spool/cron/crontabs/username. They can add new cron tasks is by using the crontab command. To edit their crontab, they should type in:
crontab -e
Root can edit another user’s crontab by typing in:
crontab -u username -e
Processes can be scheduled with a line containing the instruction in the following format:
Minute Hour Day Month DayofTheWeek Command
An asterisk instead of a number for example in the month column means that it will follow the instruction regardless of which month it is. If you put 1-4 in the day column it will follow the instruction on the first to the fourth of the month, while 1,2,4, means that it will follow the instruction of the first, second and third of the month.
To restrict the use of cron to a particular set of users, or to specifically exclude some users, alter the files /etc/cron.allow and /etc/cron.deny.
Filed under: Processes | Leave a Comment
Important directories
Linux installs a range of directories on the hard disk. Here are some of the most important:
/ is the root of the filesystem.
/boot is where the Linux Kernel and Bash are stored.
/home is where the each user’s files are stored.
/root is where the root user’s files are stored.
/etc contains configuration files.
/etc/skel is where you put files if you want them to appear automatically in new users’ home directories.
/dev is where the devices on the system, like CD-Rom drives and modems are represented.
/bin is where many system commands are stored. Imagine an inventor’s garage – it might look like a bin but it contains lots of useful tools.
/usr/bin is like /bin; the difference is arbitrary.
/sbin and /usr/sbin contain system commands only available to root (the superuser).
/lib contains program libraries.
/mnt contains mount points for removable media.
/opt contains optional programs.
/proc contains currently-running Kernel-related processes.
/tmp is where the system stores temporary files.
/usr contains little programs available to all users.
/var is for variable files, such as logs and temporary spool files for printers.
Filed under: Filesystem | Leave a Comment
File and directory permissions
Every file and directory on a Linux filesystem has permissions attached to it. They can be referred two in two formats: by a six digit set of letters or by a set of three numbers. Here’s an example in letters:
rwxr-xr-x
The first three letters mean that the file can be read, written to and executed by the file’s owner; the middle three mean the file can be read and executed by the group of users the owner belongs to; and the final three letters means that everyone logged into the server can read and execute the file.
In a directory listing (using the command ls -l), you would see an extra character before the first ‘r’, normally either a dash (-) or the letter d. A dash means it’s an ordinary file and a d means it’s a directory.
Permissions can also be referred to, as I mentioned, by three numbers, as in: 755.
The 7 means that the file can be read by the owner (4), written by the owner (plus 2) and executed by the owner (plus 1) etc. The number-based approach is commonly used when changing a file’s permissions using the chmod command, e.g.
chmod 755 file.txt
Filed under: Filesystem | Leave a Comment
There are a number of useful commands for dealing with processes. One of them is called top. This command lists, in an continually-updated way, the processes running on the system and has an inbuilt facility to a kill a particular process. However, I prefer using the command ps, in the following way:
ps -auxww | less
Then the kill command can be used, sometimes with option 9 if a process is a particularly reluctant quitter, as in:
kill -9 2099
This kills process number 2099. The -9 bit means that the operating system doesn’t bother to give the process any ability at all to close on its own accord.
Filed under: Processes | Leave a Comment
Archiving with Gzip and Tar
The best archiving tool to use on Linux is probably Gzip. By best, it is a format that everyone else using Linux can understand, and it is better at compressing files that the older compress command. A newer format called bzip2 has better compression rates but apparently not everyone can understand the format. Admittedly, that’s according to my 1999 edition of Running Linux but it’s certainly true that I’ve seen lots of Gzip (.gz) files, but can’t remember seeing any bzip2 (.bz2) files.
The gzip command compresses a file, the gunzip command uncompresses a file and the following command tells you how compressed a file is:
gzip -l filename.txt.gz
One quirk compared with the Zip archive commonly found on Windows and the Mac is that a .gz archive merely contains one file. As such, you will commonly find gzip archives called things like filename.txt.gz (it contains a single text file). To compress a whole range of files, you have to use an extra command called tar (stands for tape archive). Tar does no compression on its own: it simply lumps a selection of files into a single file for easy transportation. Once files are part of a Tar file, you use gzip to compress the tar and end up with a file looking something like backup.tar.gz.
Or you can cheat and use the z option, as in:
tar czvf home.tar.gz /home
This puts the home directory into a tar archive, compressed by gzip.
Filed under: Archiving and backups | Leave a Comment
Booting into command line or GUI
One of the machines on which I’ve installed Fedora boots directly into the GUI, the other into the command line. On the latter, I have to type startx before I get to the GUI, which is inconvenient. The reason it has defaulted to this arrangement is that I had to use the text-based installer to get Linux up and running because it didn’t have the correct driver for the graphics card (which has subsequently been installed separately).
So how should I fix this, making Fedora boot straight into the GUI? The answer is in the /etc/inittab file, where I simply change the default runlevel to 5 (from 3).
Filed under: GNOME and KDE | Leave a Comment
FTPing in Bash
FTPing has always been a graphical, drag-and-drop thing for me. When I was running a Red Hat web server a few years ago, I used to use the wget command sometimes, especially when the hosting company sent an email around asking for the software to be upgraded. But for FTP itself, I’ve been firmly a GUI man. Until now.
There are a number of commands that do FTP, including ftp, sftp and lftp. The RHCT book I’m following recommends using lftp as this is the one Red Hat exam prep guide refers to, and because it’s particularly powerful. I wanted to know if lftp (like sftp) sends passwords securely, so I looked at the man pages for lftp and was informed that lftp defaults to a secure transmission of the password where available. Excellent.
To log into an FTP site anonymously, you enter:
lftp ftp.redhat.com
or to connect with a username and password, type:
lftp username@ftp.redhat.com
or
lftp -u username ftp.redhat.com
From there you have a Bash-style command line with the ability to enter commands like ls. The important extra commands are: put and mput, along with get and mget (the ‘m’ lets you work with multiple files. To finish the FTP session, type quit.
Filed under: Network clients | Leave a Comment
Colourful ls
Some systems display the ls command’s output in black and white. On Fedora, it’s in colour, thanks to the settings of a file called /etc/DIR_COLORS (individual users can set their own colours with a .dir_colors file in their home directory). By default (on Fedora at least) ls is set up with the following colours (among others): a directory is blue; a symbolic link is cyan; a named pipe is yellow; an executable file is bright green; an archive is red; and an image is magenta.
Filed under: Filesystem | Leave a Comment
Concatenate
The cat command is short for concatenate, which I looked up in the dictionary and which means “to link or join together”. Essentially, it will display the contents of a text file with another text file (or files) directly under it, as in:
cat file1.txt file2.txt
Filed under: Text processing tools | Leave a Comment
Towards the exam
As you may be aware, I’m learning to take a Red Hat Certified Technician exam. I’m a fairly knowledgeable geek, yet there’s a lot of material for this exam that I’m learning for the very first time. The really difficult bit in the exam, it seems to me, is the hour where they put you in front of a seriously messed up system and tell you to fix everything (without reinstalling). Ordinarily, I’d rely on Google to help me fix difficult problems (for example, typing in an error message and reading discussions on internet forums). However, no internet access is allowed in the exam. Put it this way, there are no multiple guess choice questions: you either fix the problem or you don’t. I understand the pass mark is 100%.
That said, it does make the qualification a worthwhile one. I have two months to study for it, and I’m already learning quite a lot.
I took a trip to the library the older day and picked up three books: Running Linux (O’Reilly) because I liked the look of its chapter on filesystems; Linux Shells by Example (Prentice Hall) for its sections on Sed and Awk, which I’m keen to get to grips with; and, most importantly, Red Hat Certified Technician Linux Study Guide (McGraw-Hill/Osborne).
Filed under: RHCT | 1 Comment
Using KDE instead of GNOME
GNOME vs KDE is often a flame war and I don’t feel like pouring any petrol over that. That said, given that GNOME is the default in Red Hat Enterprise Linux (along with SUSE, another major business Linux distribution), and as I’m learning for a Red Hat exam, GNOME’s where I’m going to be spending most of my time. Nevertheless, I wanted to try out KDE again, so I installed it.
There wasn’t any obvious way of switching to it in Fedora. The way to do it is to go into the command line and type:
vim .xinitrc
In Vim, I created a file containing the following:
#!/bin/sh startkde
I saved it and then typed:
startx
Voila! The opposite of startkde is not startgnome, by the way, but gnome-session.
Filed under: GNOME and KDE | Leave a Comment
The Bash command prompt
I hadn’t picked up on this until today: the Bash command prompt changes depending on whether you are root or not. If you are root, it looks like # while if you are a regular user it looks becomes the $ sign. Neat.
Filed under: Bash and its associates | Leave a Comment
Recent Entries
Categories
- Archiving and backups (1)
- Bash and its associates (10)
- Books (2)
- Documentation (1)
- Fedora 8 (3)
- Filesystem (4)
- Getting hardware working (2)
- GNOME and KDE (2)
- Network clients (1)
- Processes (3)
- RHCT (1)
- Software (1)
- Text processing tools (2)