This
web site is written with the someone new to Linux / Unix in mind. Many of the
Tips are for Redhat 7 or older versions, but should work with newer versions
of Linux. I will be updating this page in the days to come, with more commands,
examples and tips for newer versions of Redhat and Fedora Linux.
At home and work, I'm running Redhat 7.3, Redhat 9,
Fedora Core 2, SUSE 9.1 and Freebsd Unix, I have used many other distro's, to include
Slackware, Debian and Mandrake. Everyone has their favorite version of Linux,
usually the distro they know the best or use the most. The Linux purist will
only use distro's like Debian or Slackware because they have no corporate ties.
Many like a distro for the slick installers or ease of use. What ever distro
you settle on remember, they're all Linux at the core.
Seeking Help
There may be errors contained in this document, if you notice them please e-mail me, admin@linuxoperations.com
Note -- Disregard any ' ' when re-typing commands.
Warning - Root Operator has full access to the system, and can destroy it all in the blink of an eye. The moral of this story, when logged in as root be careful. Better to login as regular user then "su root" to do what ever admin task you have to do then exit back to regular user. You've been warned.
Man pages - Help files with more info on most any command then you will ever
want to know. Sometimes they present a challenge to figure out, even simple
syntax. Remember man pages were written by Geek's for Geek's, so just suck it
up and get as much as you can out of them.
| Example | 'man ls' |
| 'man rpm' |
| Example | ls --help |
![]()
| cd | Change Directory |
| Example | To change directory using an absolute path you must always start at the / of the filesystem. 'cd /etc/rc.d/init.d' to move three directories down from / Now if we want to move to the directory /etc/samba we can use the relative path to samba directory. First we need to move up the directory using ../ from the current location. 'cd ../../samba' takes us up two directories and into the samba directory. If you are logged in as johndoe user and your in the /etc/samba/ directory and you want to change directories to your home directory just type 'cd' Refer to the 'tab' key below to make typing long relative paths a snap. |
| cat | Print contents of a file to screen or to send contents of one file into another. For something useful, cd /proc then do a cat interrupts, or cat ioports etc. to get some useful system information. 'cat -n somefile' will display with line numbers. |
| chown | Change ownership of a file or directory. |
Example |
'chown
root kinit' root is now the owner of a file call kint |
| chgrp | Change group ownership on file or directory |
Example |
'chgrp
root kint' The file kint now belongs to a group called root |
| chmod | Changing file permissions |
Example |
'chmod
777 test.txt'
'chown root:root kinit' 'chmod 4755 kinit' |
| Note | When
you list files with ls -al you should see something like -rwx-rwx-rwx
1 owner group size date time <filename> the first set of permission
flags "rwx" represents (read,write,execute) "owner"
followed by the next three which is "group", then the last three
is "world" (or everyone if you will). Now the confusing part,
each set "rwx" represents 421 or when added together =7 So to
set a file you would type Ex: 'chmod 777 test.txt' Which would set test.txt
to rwx-rwx-rwx
chmod 700 test.txt would give you -rwx------- The owner is the only one who can read, write or execute that file. EXCEPT FOR ROOT OPERATOR WHICH CAN DO AS HE/SHE DAMN WELL PLEASES 'chown root:root
kint' changes owner and group of kint to root. chmod 4755 turns on the
suid bit allowing a regular user to run the file with the permissions
of root owner. |
| df | report on mounted filesystems, size, used, mount points etc. |
| Example | df -a |
| du | Disk usage. |
| Example | 'du /usr/share'
shows disk usage for all sudirectories under /usr/share 'du -k' would show sizes in kilobytes. |
| dmesg | When the computer boots, lots of information scrolls by very quickly. Information about what is getting loaded, or certain items that may not be configured correctly, messages that are useful in trouble shooting, etc. Type the command 'dmesg | less' in any terminal window, now you can view it a page at a time. Type 'q' at the end to get back to the prompt. |
| file | Problem:Trying to untar a file 'tar -xvf /tmp/whatever.something.tar' and you get an error that it is not a valid tar file. |
| Note: | Using
the 'file' command we can find out what type file it is. Remember Linux/Unix
does not care about file names and extensions like Windows. TYPE 'file
/tmp/whatever.something.tar' and you will get a message stating that this
is in fact a gzipped tar file not just a tar file. |
| Example | So you would need to issue 'tar -xzvf /tmp/whatever.something.tar' to decompress and extract the file. |
| find | find command is used to find stuff. Sounds easy right, in fact find is one of the most confusing of all commands due to the finicky syntax. |
| Example | If you want to search the whole harddrive for a file, 'find . -name myessay.doc' To do something a little more powerful try, find /stuff -name "*" -exec chmod 666 {} \ ; This starts search in /stuff finds all files and then runs them through chmod changing their permissions to rw-rw-rw- |
| grep | Used
to find matching patterns in files. |
| Example | 'ps -ax
| grep netscape' This would show you all processes running on your machine (ps) and then piped through grep to find which process netscape was running under.For Example your running X-Windows and a program locks up. You find that you cannot shut the program down and you have no control in the X-Windows environment. Do we re-boot? NOT! Try this, press ctrl-alt-F1 thru F4 this should take you to a command shell. Now use the ps -ax | grep 'your program' After you find the process number (729 or something) run kill -9 your process number. Then ctrl-alt-F7 to return to X-Windows. |
ifconfig
Example |
This command is used to configure NIC cards with IP address, Bcast, network mask etc. Also shows status of network services such as PPP and Loopback (lo). To get info on network status type 'ifconfig -a' To configure a ethernet card ( first ethernet card 'eth0')
the command line would look something like: For more information on network subnets please see subnetting document. |
| ldd | Gives you information about what libraries are required by any given program. |
| Example | ldd kinit (The output will list libraries required for a program 'kinit' ) |
| ln | Create a new name for a file. usually used to create symbolic links to files. |
| Example | 'ln -s
/dev/cua2 modem' This will create a symbolic link from modem to the device /dev/cua2 (which is your modem on comm 3) |
| ls -al | List all files (even hidden ones) and directories. |
| ls -la | List only directories. On some machines this does not work, don't know why. |
| ls -F | List
files with syntax showing what type a file it is. * / @ : = Blank space, i.e. nothing there, means it is just a regular file. |
mc |
Midnight Commander --Very handy Editor and File Manager. Just type 'mc' or 'mc -c' (-c for color if you are getting a black and white screen) in any terminal. F3 will allow you to view files, F4 will allow you to edit, F2 to save, plus plenty more on the drop down menus. If you mouse doesn't work for what ever reason, F9 will drop down a menu, then just arrow left or right to the menu of your choice. The insert key will select files for you, F8 will delete them, if you have proper permissions. F5 copy, F6 move, and F7 make directory. F10 to exit . To exit when using mc during telnet session type 'exit' at the space at the bottom of the screen, then hit enter. |
| netstat
Example |
Display network connections, routing tables, interface statistics, masquerade connections and netlink messages. 'netstat -i' will print a table of all (or the specified interface) networking interfaces. Try also 'netstat -rn' |
| passwd | Used to change the password of current user or used as root to change passwords of other users. |
| Example | As root 'passwd' username |
| ps -ax | Will show you all process currently running. Also try 'top' |
| pwd | Print working directory |
route
Example |
Used
to create entries in the IP routing table. Used to to set up static routes
to specific hosts or networks. 'route add -net 192.168.150.0 netmask 255.255.255.0 eth0' adds route to 150 network thru Ethernet card eth0, or you could add the loopback route with 'route add -net 127.0.0.0' |
| su | Allows you to become superuser (i.e. root). You should login as a regular user then use the su command to become root. In a terminal window type su then hit enter and then type password. |
| Note: | using 'su -' (notice the dash) will load roots enviroment and switch you to roots home directory amonst other things. If you have the root power you can also use the su command to assume the idenity of any regular user. |
| rpm | Redhat Package Manager - This is becoming the default way programs are packaged. |
| Example | 'rpm
-ivh <program name>' As in the following -- 'rpm -ivh mesa-3.0-2.i386.rpm' i - install v - verify h - hash (makes little pound symbols accross screen while it's installing lets you know something is happening) --force (can be used after the -ivh if the program is complaing about being loaded. 'rpm
-qa' Tells you all the packages installed. |
<Tab> |
The mighty <Tab> key. While typing in commands in a terminal, pressing the 'Tab' key will finish filling in the command for you. |
| Example | Type 'cd /usr/sh<Tab>' it should have finished the 'share' for you. Very handy when your dealing with files with long names, like RPM files or sub directories six levels down. If there is more than one choice, it will give you a list of them, you may have to type the first few letters then hit the <Tab> again. If you are spelling something wrong and there are no choices it will beep at you. |
| tail | Used to output the last part of a file. |
| Example | 'tail
/var/log/messages' This will output the last ten lines of the file
'messages'. 'tail -n 30 /var/log/messages' will output the last 30 lines. 'tail -f /var/log/messages' will output the last ten lines and append any new data as the file grows. |
| Note | To do something really cool get a program called 'paralogger'. Does the same as 'tail -f ' but prints the output directly to your X-11 desktop inside a transparent window, way cool. There are many versions of this program, just do a google search for 'root-tail', or give this a try http://gtk.no/paralogger |
| tar | Extract or compress archives. This is how alot of programs are packaged when you download them from the web. |
| Example
Example |
tar -zxvf
<filename> This extracts a compressed tarball. z - uncompress .gz x - extract .tar v - verbose (show what is happening) f - file name to follow To create a compressed tarball of a directory and all subdirectories and files under it. tar -zcvPpf <filename>.tar.gz
/directory |
![]()
1. Problem: During boot kernel panics because it can't boot correct partition. Solution: At LILO prompt pass ' linux=/dev/where your root partition is'
Example:
LILO: linux=/dev/hda6
2. setserial - used to change the IRQ of devices, i.e the damn modem you can't get working.
Note:
My modem would not work at irq 4 or 10, works great at irq 5, can't explain
it, no conflicts with anything else, just refuses to work unless it is set to
irq 5.
Example:
setserial /dev/cua2 irq 5 (This would set the modem on com3 to irq 5) Place
that line into your rc.local file at the bottom, to make it execute on every
re-boot.
3. PPP Tips: Can't log into you service provider unless your ROOT, (Which is a very bad idea). The problem may be the permissions on the pppd Try this, cd /usr/sbin (if your pppd is located else where, then go there instead) then ls -al pppd and have a look at the permissions.
Do the following: chown root.root pppd
chmod +s pppd
If that doesn't work for you try this: chmod 4755 pppd
Note: The wrong permissions could also be the cause if your pppd dies a few seconds after you connect to your ISP.
4. sndconfig - May help you get that damn soundcard working. Just type sndconfig at the command prompt and the program will start.
5. hwdiag - To aid in determining the hardware installed in your system. I have had limit success with this utility, you may fair better. At the command prompt type 'hwdiag'
6. To run commands in the directory your currently in, use ./<the command>
Example: To run the Netscape install script, cd to the directory, then type
./ns-install
7. Hard Drive Repair - Your uptime is going good, when a storm kills the power, and of coarse we don't have an UPS, then when you reboot, your hardrive has corrupt files. The promt allows you to enter maintencee mode, and running fsck is not fixing the problem, What Now? Try and run e2fsck -f /dev/<yourdrive>.
Example: e2fsck -f /dev/hda5
Now do that for all your volumes. WARNING DO NOT TRY AND RUN e2fsck ON A PARTITION THAT IS MOUNTED. For more info check 'man fsck' or 'man e2fsck' 'tune2fs'
8. Samba
If you have never heard of Samba, they
call it the GLUE that makes Windows stick. Samba is an open source software suite that
provides seamless file and print services to Windows clients, i.e. it will allow a Windows
machine read and write to the Linux file system.
At home I have an old 60 MHz machine
acting as a file and print server over a ethernet network. I loaded Redhat 5.2 and Samba
on a 4 Gig harddrive, now when I fire up my Win95 machine and open Network neiborhood it
sees the Samba box and thinks it is a Windows NT file server.
To
stop and start samba, a.k.a smbd and nmbd. Type: etc/rc.d/init.d/smb stop (To
Stop) etc/rc.d/init.d/smb start (To Start) or etc/rc.d/init.d/smb restart (To
do both) . You should see "Shutting Down SMB services: nmbd "Starting
SMB services: smbd nmbd
smbstatus -d (will print message about the current samba setup)
smbstatus --help for more options
9. Swat - Graphical front end through Netscape for configuring the smb.conf file for Samba.
To
setup swat follow these steps.
A. Set your /etc/service and /etc/inetd files like stated in the swat.8.html
file.
B. Also insure that the interfaces= line in smb.conf contains proper IP address
to enclude localhost IP 127.0.0.1
C. Put this line in your rc.local file ' /usr/sbin/swat -s /etc/smb.conf ' That
tells swat where to find the smb.conf
D. Also make sure Samba is running correctly i.e smbd and nmbd.
10. Webmin and Usermin - To manage all your Admin
needs give Webmin and Usermin a try http://www.webmin.com/ . You can download
tarballs or RPM packages here http://www.webmin.com/download.html or http://www.webmin.com
/udownload.html. You will notice that some of the files end in .noarch.rpm ,
what this means is the RPM is architecture independent.
More info visit
http://us1.samba.org/
http://eunuchs.org/linux/samba/index.html
11. Apache Web Server
To start Apache a.ka. Web Server type:
cd usr/apache/bin (Your Apache directory may differ) Next type ./apachectl (Note that is a
small L, NOT a one on the end)
You should see ./apachectl start: httpd started
More info visit
http://www.apache.org
http://www.apacheweek.com/
http://www.redhat.com/support/docs/howto/
12. TrueType
Fonts Page