Hints and Tips For SysOps Running LinuxBy Janis Kracht 1:261/38 (firstname.lastname@example.org)
Though many of us have converted our Operating Systems, bbs software, echomail tossers, and mailers to new ones many times, changing one's setup to run under Linux can be perhaps more challenging than anything else ever experienced <smile>.
Hopefully this article will be of some help if you have just switched
to Linux, or if you are about to do so. I'll show you some comparisons
between DOS and Linux so that you can see that Linux isn't as foreign as
it might at first seem, and then I'll provide some scripts that I've written
to perform various functions on my bbs system. Lastly, I'll also include
a few notes regarding some things you should _make sure_ do when you install
linux. Security under Linux is a very large topic however, so I will cover
that in more detail in a later article.
First off, let's look at some commands that you might commonly use under DOS, and their Linux counterparts. As you'll see, there are some commands that do not have an equivalent under DOS (i.e., I'm not counting DOS GNU utilities, etc. since these are not generally part of the standard DOS distribution.)
Tip: It would probably be a good idea to type 'man command', or 'info command', or 'command --help' without the quotes to see all the options of these Linux commands.
|Simplistic command interpreter
Advanced command interpreter
Interpreter for perl scripts
Interpreter for awk scripts
|Long format directory
Long format directory
Wide directory format
Remove a directory
Make a directory
Recursively delete a directory tree
Some Linux examples:
ls -d .* Show only "." directories. (these are
often configuration files, etc. for
various programs). The -d indicates that
only the directory name should be shown,
not the contents.ls -ltr Sort by date, reverse order.ls --color=auto Turn on color for file types in directory
ls -1 -1 (one) shows file names in column list
with no other info
Example of ls -1:
[janis@filegate]$ ls -1
|Copy a file
Move a file
Set timestamp on a file
Delete a file
Print file to the screen
Change ownership of a file
Change group ownership of a file
Change access permissions of a file
Write directly to a device
Create a link to a file
Some Linux examples:
mv firstdoc.txt seconddoc.txt rename firstdoc.txt
mv /janis/*.txt /afiles
move *.txt to directory /afiles.
Tip: When moving groups of files with the same filename, such as mv *.tic *.bad, you must specify a different directory. To move files such as *.bad to *.tic, you can use the script in this article, mvbad2tic.
Enter these in your /etc/profile to make them global or ~/.bash_profile to make them local.
You can also enter them on the command line, just for that session. If you type:
you can then use md instead of mkdir.
|Search for a string in a text file
Search for a file
Search for a file via a database
Create searchable databas of files
Sort a file
Translate, squeeze, and or delete characters
from standard input.
An example of find:
Tip: ctime option in the find command will show status of a file that was last changed n*24 hours ago. daystart measure times (for -ctime, and other options for find) from the beginning of today rather than from 24 hours ago.
[bbs@filegate /home/bbs]$ find /home/ftp/pub -daystart -ctime 00
[bbs@filegate /home/bbs]$ _
|Modify the partition table
Create a file system on a partition
Format a floppy disk
Test a file system for errors
Turn on a swap partition
Turn off a swap partition
Attach a file system to the root file system
Detach a file system from the root file system
View amount of disk space available
View amount of disk space used by a directory recursively
Some examples of Linux commands:
The mount command with no parameters specified shows you the devices currently mounted.
[bbs@filegate ~]$ mount
/dev/hda1 on / type ext2 (rw)
none on /proc type proc (rw)
/dev/hdb1 on /export type ext2 (rw)
none on /dev/pts type devpts (rw,mode=0622)
Getting Help with Commands:
|Get help on a command
Get help on a general topic
Search the whatis database
Make the whatis database
Classify a file
Editing and Printing
|Editor for novices
Editor for advanced users
Print a file
Wordstar compatible editor
Programming environment and editor
Backup, Compression, and Archival
|n/a||bzip2||A block sorting file compressor,
using Burrows-Wheeler block sorting
text compression algorithm, and Huffman coding.
|bzcat||Decompresses files to stdout|
|bunzip2||A block sorting file compressor|
|bzip2recover||Recover data from damaged bzip2 files.|
|pkzip||zip||Create a zip file|
|pkunzip||unzip||Extract files from a zip file.|
|n/a||gzip||Compress or decompress files via GNU zip|
|n/a||compress||Lempel-Ziv compression program|
Archivers which you may have used under DOS are available:
Viewing multiple Archives with zip and rar:
As you probably know, under DOS, unzip -v filename.zip,
will list the contents of one archive.
To list the contents of multiple zip or rar archives, enclose the argument in quotes:
unzip -v "*.zip"
[bbs@filegate bbbs]$ unzip -v "*.zip"
Length Method Size Ratio Date Time CRC-32 Name
1706292 Defl:N 560625 67% 09-14-99 15:57 a18214bc NODELIST.253-------- ------- --- -------Archive: ppphowto.zip
1706292 560625 67% 1 file
Length Method Size Ratio Date Time CRC-32 Name
158718 Defl:N 48642 69% 10-16-99 20:32 b4ad98a9 PPP-HOWTO-------- ------- --- -------2 archives were successfully processed.
158718 48642 69% 1 file
Tar and gzip are used commonly on Linux. Often you'll see archives with tgz extensions, .gz, or no extension at all.
Tar doesn't compress the data, that's why gzip, a compressor, is used with it.
You can use the file command to see how the file is archived/stored
if there is no extension or if you are just curious:
[bbs@filegate bbbs]$ file ZPMF025D.TGZ
ZPMF025D.TGZ: gzip compressed data, deflated, last modified: Thu Jun 8 04:55:16 1995, max compression, os: Unix
So you'd need to un-gzip this file first, then un-tar it.
gzip -d ZPMF025D.TGZ
This results in the file ZPMF025.tar
To list the contents of the tar file, type
tar tf filename.tar
To extract the tar, type
tar xf filename.tar
There are options to "keep old files" with both gzip and tar which you may also want to include on the command line. The default action is to remove the original tar. See
tar --help and
gzip --h for more info.
This shortcut extracts both the tar and gzip files in one command:
tar xvzf filename.tar.gz
The "z" flag says "un-gzip before un-tarring". The same
flag works in reverse when tarring.
Some BASH Scripts
One of the neatest things about *nix systems is that any file can be
made executible by simply changing the attributes of the file.
Of course, if the text file doesn't have any useful commands in it, it won't "do" anything <smile>.
Here are some scripts I've written for my bbs - none of these contain
any startling ideas, and I don't doubt a number of them could
be done better, but you can feel free to modify them as you like or need.
info bash will show you the system's man pages for these scripting keywords.
To use these scripts, save them to a file and then make them executible
with 'chmod a+x filename' without the quotes.
To call them you can type 'sh filename' without the quotes, where filename is the name of the script.
Again, scripting is a very broad subject ... looks like I will be writing yet another article concerning that subject later :)
# the above must be the first line in the script.
# the # symbol specifies a comment line
mylist="`ls -1 *.bad`"
for file in $mylist
f=`basename $file .bad`.ticdone
mv $file $f
# make_zic takes a file and it's accompanying
# tic and puts them both in one zip archive aka
# Allfix's zic option
dir -1 -I*.tic -I*.sh -Iticlist -Iarchives >> archives
dir -1 *.tic >> /home/bbbs/binkd/work/ticlist
for file in `cat archives` do
for tics in `cat ticlist`
test=`grep $file $tics`
f=`basename $tics .tic`fi
zip -jm0 $f.zic $file $tics
mv *.zic /home/bbs/binkd/barry
chown bbs.bbs /home/bbbs/binkd/barry/*
Next, mvfile2in.sh uses another file you must create named dirlist.
dirlist contains the names of your users' home directories which will most likely be the same as the username.
You can create this file with the command: dir /home/* -1 > dirlist
Edit it to remove other entries you don't want, like ftp, etc. which may be in the /home directory.
# Move files from a users' inbound to the bbs' inbound
# Tests to see if user is online before moving anything.
for f in `cat /home/bbbs/dirlist`
if ps aux | grep ^$f
echo "===user $f online==="
elif test -e /home/$f/*/*.bsy
echo "$f bsy-flag exists"
echo "===safe to move files from $f==="
mv /home/$f/in/* /home/bbbs/inbound
get_desc can be used to import file descriptions to a files.bbs or descript.ion type file list.
# import file_id.diz to files.bbs or descript.ion type file
dir -1 *.zip > dirlist
for f in `cat dirlist`
unzip -pC $f file_id.diz >> FILE_ID.DIZ
if [ -f FILE_ID.DIZ ] ;
# this script uses an abbreviation for the the test command, [ and ].
# I believe Pertti Heikkinen posted this in the bbbs.english echo.
tr '\n\r' ' ' <FILE_ID.DIZ >tmp.fffi
echo $f `cat tmp.ff` >> descript.txt
rm -f FILE_ID.DIZ tmp.ff
Some Install Concerns for the SysOp Installing Linux
system <grin>. Issuing a command like rm -r from the / directory as user root will surely go through the entire directory tree
and do just what you told it to do (rm -r deletes recursively... <ouch>. )
Of course there will be times when you must log on as root to do things such as install your apache web server, configure your ppp connection, etc., but that is really the only time you should log in as root. Likewise, you should never log in as root in XWindows as user root, except as above. XWindows can destroy your data if you are user root and are playing with commands.
Use the adduser command to create other users on your system
which you can use on a daily basis.
To add a user, as root, type
where username is the name you have selected, 8 characters or less.
Linux will let you use longer names for the users, but will truncate them.
The adduser command adds the user to the passwd file in /etc/passwd, and
unless you specify otherwise, creates a directory off /home which is that
user's 'home' directory. These limited-access users can only harm the files
they own in their
home directory. Next you assign that user a password with the passwd command by typing
The passwd command prompts you for this users' password, 8 characters
or less since again it will be truncated if it's over 8 characters. The
password you choose should be a combination of upper and lower case
alpha characters and numbers.
Tip: Try to make the password something that means something to you, then use the letters of the words to make up your password.For Example:
I Really hate Chocolate cake I'll take 1 = IRhCcIt1
The last section of this article is pretty important. With the number of systems online 24/7, these issues cannot be ignored. If you think your system is safe from those who would test and probe your system for ways of gaining illegal entry, think again.
1. After installing linux, the very first thing you should do is pull up your favorite text editor, and edit the inetd.conf file which lives in /etc (/etc/inetd.conf). Comment out every single line in that file except for the one that refers to ftp if you figure to use ftp. If you think this sounds drastic, well, it is. And it's necessary. If you leave the file as is, you are leaving an incredible number of ports and services open to trouble-makers who will (most likely) be port-scanning your system over and over again looking for weak points. You probably won't need any of the services you are commenting out - and some of them, like rlogin, are incredibly famous for having holes where hackers can gain access to your system.
2. Use ssh, (Secure Shell) instead of telnet. Comment telnet out from inetd.conf. If you think are going to need telnet so that you can telnet into your system remotely, DON'T. Use Secure Shell instead. If Secure Shell isn't already on your system, go to http://rpmfind.net/ and download and install it.
3. If your distribution of linux installs wu-ftpd, install
a different ftp daemon, such as Bero-ftpd, or Proftpd. Why
Well, Wu-ftpd has been known over the years to have holes where creeps can gain illegal access to your system. Technically speaking these holes are plugged with new releases, but ... in general it is a good idea to install one of the other daemon's mentioned.
4. All of the above is good, but don't rest easy yet.. Another thing you must do is contantly stay aware of upgrades to the software you use. If, for example, a new version of bero-ftpd is released, install it. Upgrades under linux are not always done to make the software prettier or sexy <grin>. The site that maintains the software you use will always post what type of upgrade the software is and whether it is a security upgrade.
The following articles may be helpful - they contain some of the same information as above, but some additional information as well.