Sponsoring website: Emergency Boot Kit

An Introduction to
Linux Console Commands
using "tomsrtbt" Boot Disk

Copyright © 2002 by Daniel B. Sedory

You may copy this page for Personal use only!
Any other use must have the author's permission!

Once you've decided to study Linux with
this page, you need to read these:

[ How to Download and Install  tomsrtbt  Boot Disk ]

[ What Happens when you first Boot Up with  tomsrtbt  Disk ? ]
( Includes: How to Login and get a Command Prompt . )

NEW: [ How to Setup the Bochs Emulator for tomsrtbt ]
I highly recommend using this FREE emulator to simulate running
tomsrtbt boot diskette in a window while reading these web pages in
a different window! You'll be able to have a 'hands on' Linux learning
experience while still having access to this page and any other helps.

( Although this page was created mainly for those unfamiliar with UNIX/Linux commands, some of the
examples here examine the inner workings of "tomsrtbt" boot disk; which may interest even an expert. )

This is a new project at The Starman's Realm...
I intend to continue adding information here,
and your feedback and questions would be
appreciated at this time. Although this page is
helpful for Windows users who want to have
some knowledge of Linux and UNIX commands
without having to do a Linux HDD install, I'm
sure there are quite a few Linux users that have
become somewhat GUI (Gnome/KDE etc.)
dependent too and could benefit from learning
How to use one of the ultimate Linux Rescue
diskettes available today !!!

Every Computer Tech should have one of these
diskettes in their toolkit !!!



What kind of Linux Commands are these?

 

You might be thinking, "Hey, what's this UNIX stuff? I thought we were learning Linux?" Well, here's a tiny history lesson: Linux was started as an open source project in 1991 by Linus Torvalds, when he was a computer science student at the University of Helsinki, in Finland. Having become quite familiar with UNIX at the University, he and many contributors to Linux wanted a UNIX-like OS for their PCs at home. So, Linux was purposely designed to include many useful UNIX commands.

The major differences between these two OSs are:
1) Their file systems. UNIX basically seems to use either NFS or HP-UX although another UNIX-like OS called BSD, distributed as FreeBSD or OpenBSD, uses UFS, whereas Linux might use the older Minix -- which tomsrtbt uses (to save space), ext2 or a "journaling" ext3 and a few different Reiser file systems; plus a couple other file systems just for swap files! And...
2)
Just exactly how Linux carries out its functions on a PC using its kernel software (the heart of the Linux OS); which is definitely beyond our scope here!

 

Conventions used in this Document

1) Commands which you are to ENTER at the prompt (type in at the command line and then press the ENTER key), will be shown in a bold, blue font like this: command.
2) "Tom" refers to Tom Oehser, the creator of the tomsrtbt boot disk (see D/L page).

 

tomsrtbt will also allow you to access MS-DOS and Windows file systems (FAT12, FAT16 and yes, FAT32 and NTFS too) on your hard drives! Not just to check what files are there, but with full read and write* capabilities. "But," you might say, "my computer's BIOS can't access the drives without a BIOS overlay!" Well, Linux don't care... it don't need no stinkin' BIOS data to manage large drives!  ( I exchange files between my Linux and Win98 drives all the time, even though Windows couldn't use all of that 40GB drive without having WD's EZ-DRIVE loaded on it!) With all of these capabilities, shouldn't every tech learn how to use tomsrtbt?!

*Note: According to Tom, "NTFS is in the current version [ 2.0.103 of tomsrtbt ]. But, it is read-only. Just use mount -t ntfs to mount NTFS drives. The NTFS drivers in Linux are not safe for write access, anyway."


Reminder: Many computer programs are not perfect! People program them, and people make mistakes! tomsrtbt does have some 'bugs.' See the "ToDo" list at the end of tomsrtbt.FAQ file. However, most of our examples here deal only with files in Memory or on a floppy diskette, so there shouldn't be any data loss problems at all. But, don't blame me for something you tried on your hard drive and got it messed up! (I'll still try to help you recover your data in any case.)

tomsrtbt uses (as of this writing) Linux kernel version 2.2.20 with ext3 support, but in order to keep its size to a minimum, the console commands are sometimes mere shadows (script files) or trimmed-down versions (all lumped together into a single executable; like the one from BusyBox) and a few programmed by Tom himself, rather than those you'd normally find in a full Linux distribution! However, tomsrtbt along with these pages and many other online documents, gives you a practical way to learn how to use many common Linux/UNIX commands without having to install a Linux OS on your hard drive!




Session 1

TIP: If you return to your computer and see a blank screen (this will happen very often in the Bochs Emulator window!), pressing either of the CTRL (Control) or Shift keys is the safest way to turn it on again.

Bugs me too: There's one thing about tomsrtbt that gets me a bit upset at times... You can only use the RIGHT and LEFT ARROW keys for moving the cursor and then the BACKSPACE key to delete any mis-typed characters! At least the UP and DOWN ARROW keys give you access to a reasonably sized command-line history (previous commands you've already entered).
     Most Linux installations have the Bash shell which allows use of the DELete key; and may even use the Home and End keys for jumpimg to the beginning and end of the command line. Whereas, tomsrtbt uses the smaller Ash for its shell.

 

Some Basic Commands


    If you haven't read the page,
What Happens when you first Boot Up with  tomsrtbt  Disk ?, at least skim it. There's some important information on the page!

    Now that you finally have a command prompt (#_ ) on your screen, we can get started. Let's try the command, ls (which basically means to list files and directories). After entering this command, you should see this on your screen:

#ls
bin etc mnt sbin usr
cdrom fl not tmp var
dev lib proc tomsrtbt.FAQ  
#_        
Idealized version -- using data from tomsrtbt 1722 kb diskette.

In the display above, the items in blue are directories (the actual color displayed by tomsrtbt is dark blue to violet). Items colored in cyan (such as the sbin directory) are soft links: Rather than being the actual file or directory, a soft link is simply an alternate name which points to the real directory or file. The item, /sbin, in tomsrtbt is just a link to the /bin directory. If you performed an ls command on /sbin, you'd simply see a listing of everything in the /bin directory. The display is slightly different (only a couple extra files) for the 2880 kb version of tomsrtbt :


Capture of Bochs Emulator screen using tomsrtbt 2880 kb image file.

[ NOTE: As long as we remain in the root directory (/), it doesn't matter if we use a / in front of these directories or not when entering a command. But once we cd (change directory) into a directory below the root, you'll need to begin a reference to files or directories outside of that directory with a /; unless it's a file inside that directory or in some subdirectory below it. Thus, /bin was necessary in the text above to uniquely identify that directory; especially since there's also a /usr/bin directory in most Linux installations. ]

Items listed in green, such as tomsrtbt.FAQ refer to a file that has at least one of its executable access bits turned on (we'll learn more about this below when covering Permissions). However, just because a file is marked as an executable, doesn't mean that it's a program (or even a script file)! In reality, tomsrtbt.FAQ is just a plain text file; which would normally have a light-gray color (as does any file that isn't a link, executable or a couple other things you haven't seen yet). The cat command (short for "concatenate files to stdout") is often used to display short text files on the screen, but if you enter cat tomsrtbt.FAQ to view Tom's FAQ, you won't even be able to use the SHIFT and PageUp key combination to see all of it! ( Remember, the screen buffer works fine for things you may have missed just a handful of screens back. ) So, how are you going to read all of it?

Well, the best way to view any large text file in Linux, including Tom's "FAQ" file, is by using the less command. In tomsrtbt, the more and less commands are just links to the same binary program (proof for that is found below), so you could just as well use the more command (which some DOS/Windows users might might be more familiar with). But in a full install of Linux, less is always better than more! So, you should practice using the less command like this instead:
less tomsrtbt.FAQ ( By the way, you must use the capital letters 'FAQ' here, because all names in Linux and UNIX are case sensitive ! )

After entering the command followed by a text file's name, you'll notice a 'highlighted' area in the lower-left corner of the display similar to this: --More--(2%). If you press the ENTER key, the text will scroll down one line at a time, and soon you'll see that the 2% changes to 3%, 4%, etc. which refers to the percentage of the file's contents you've already moved into. To jump forward by a full screen, press the SPACE BAR or the F-key (for forwards). Unless you've already scrolled past the end of the file, you can always press the B-key to move backwards by a full screen! If you want to quit, just press the Q-key. There are other commands you can use inside of more, but this should be more or less (pun intended) enough of them for now!

Oh, there is one more key that might be helpful in a large file: If you press the forward slash key (/) followed by a word, it will search for that word. Unfortunately, it won't highlight it as it does when using less on most Linux workstations. To see other function-keys for less, press the h-key (for help).

The -l option (meaning "long" or verbose) of the ls command will be a bit daunting at first, because it adds even more data than you'll find with the DOS dir command! But unlike dir, you can use multiple filenames and/or directories as parameters such as this example here:

For each file or directory, the beginning of the first column is its "file type;" either a "-" or one of the letters b, c, d, or l which indicates if it's a block device, character device, directory or soft link. The next 9 characters show the "permissions" for reading, writing and executing the file for three classes of user: its owner (user), group and all others. A column of digits follows it, most often with just the number 1. This indicates how many hard links there are to the same physical file. Thus, a "2" appearing in this column means there are two hard links to the same physical file and this is one of them. Thus, both the more and less commands (see above) must each have a "2" in this column. Once a hard link is made to another file, there's no longer an 'original' name; as far as Linux is concerned, there are just two hard links. The next two columns are the file's owner and group names. Many files in tomsrtbt are set to "root" because that's the name you logged in under. The "505" and "100" are names that were set by Tom. The next column contains the file's size in bytes (e.g., 17,845 bytes for the more/less file); with one execption: If the item listed isn't really a file at all, but a device. Devices, which are found in the /dev directory, will be listed as either block or character devices, are all colored yellow and show their major and minor device numbers (separated by a comma ",") instead of a filesize (like dev/hda1 in the listing above; which has a major, minor designation of: 03:01). Finally, the column before the filename itself is its timestamp. By default, this would be the time the file was last modified. For files that are over 6 months old, however, this will contain the year instead of the time of day. Lastly, soft links in a listing using the -l option, also list the file or directory they are linked to! Thus the last item above is listed as: usr/bin -> ../bin , showing that this is simply a link to the /bin directory (the ../ means to first go back up to the parent of the usr directory, then look for the bin directory there).

Now it's your turn to do a few 'listings' and try to find out some things about the files and directories under tomsrtbt... which, technically, is a collection of some dev/ram devices in Memory now that you've booted the diskette! Enter just ls /dev and briefly note the variety of entries there. Some of the "devices" you'll see aren't related to any physical hardware at all, but are rather useful as devices anyway! For example, we'll be using both the null and zero devices later in these lessons. Next try the command: ls -l /etc . Note the variety of files. Be careful about looking inside of files that are binary executables (using cat)! If you do so, most likely a bunch of graphics and control characters will go flying by, you'll hear beeps and your command prompt will end up looking like Hieroglyphics! That's when you need to try the command: reset while looking at the keyboard, press ENTER and hope that fixes it!

 

Some Details about Permissions
and
How to Create a New File

Looking at the /etc/issue file in the listing above, you'll see its permissions are set to: rw-r--r--. This means that only a person with "user (owner) privileges" can change (write to) that file, anyone else can only read the file. Permissions also apply to directories in Linux/UNIX. If the /etc directory were set to, rw-------, then no one but its owner could access the issue file, no matter what the settings were on the file itself. Likewise, for you to be able to execute a program, it must not only have an execute permission that applies to you, but must also reside in a directory that has its permissions set correctly as well. This is why all the directories under tomsrtbt have a minimum setting of r-xr-xr-x. Internet servers have their cgi-bin directories set to rwx--x--x (or even --x--x--x), so the files can be executed by anyone needing to do so, such as running a search program, but the actual contents of the files can only be accessed by the owner (in this case someone who has "root" or System admin. rights!).

  "So, how does one change these permissions?!" There's a special command called chmod ("change mode") for doing this. It accepts either of what I'll call the character or the Octal options. The character option is easier for most people to remember. It consists of three parts: 1) Who is affected: u - user (owner), g - group, o - others or an a - for all three of them. 2) Action: + (for add) or - (minus: remove). 3) Permissions: r - read, w - write, x - execute [ there's also an s and t, but they won't be discussed at this time]. If you wanted to remove all the 'x's from the permissions of Tom's FAQ file (since it's not really an executable), you would enter: chmod a-x tomsrtbt.FAQ at the root prompt. In order to carry out a complex change under tomsrtbt, you can separate each "action set" by only a comma (no spaces) between them like this:
chmod a+x,go-rw filename (which would allow the file to be executed by all users and remove both read and write capability from the group and others). Those who enjoy numbers; especially seeing Octal as Binary in their minds, might like using the Octal option instead. This is a base 8 number which always has the form of three Octal digits standing for the permissions bits of the user, group and others in that order ("you go..."). Thus, chmod 755 (used quite often), stands for: 111 101 101 (in binary), or for the permissions: rwxr-xr-x (can you see the digits?). To set a file with the permissions, rw-r--r--, you would enter: chmod 644 filename (which is 110 100 100 in binary). The Octal number may be preceded by a leading "0" (zero) to indicate that there's really a four digit Octal number involved here; the first Octal digit in the machine is for the suid, guid and sticky bits in that order. [ Another session will explain how to use these three bits.]

Creating New Files

    "If we create a new file under a Linux or UNIX system, what will its permissions be?" All such systems must have a pre-defined default for this occurance. Under any *nix system, entering the command: umask (with no parameters) will show you what that default is in a 'negative way.' For example, tomsrtbt will reply with: 0022 which means that both the group and others will have their permissions set to read only (the '4' bit) for any new files created by the owner. This seems a bit odd at first glance (since the opposite of a 2-bit here would be both a 4 and a 1 -- both read and execute), but you need to understand that for any file to be executable on a *nix system it must be explicitly set as such after being created or a very serious security flaw would exist! If, however, the owner creates a new directory, then things make more sense: with a mask of 022, a new directory's permissions will be: rwxr-xr-x (no masking on the owner, and the 2-bit masked for group and others). You can change your mask to a state many prefer by entering: umask 026 (which masks both the 4- and 2-bits for others) and gives a new directory these permissions: rwxr-x--x. Finally, a mask of 077 would completely hide all new files and directoies from all but the owner (and, of course, root and anyone else having SysAdmin priveleges). [Summary: A mask of 000 would turn on every permissions bit; not very safe. Masks 022, 023, 026, 027, 033, 037, 066 and even 077 might all be useful at some point, but any with a 4 or 5 are worthless; figure out why?]

So, how do you make a new directory or file? Making a new directory is easy! Just use the command: mkdir dirname . But before you try it, let's cd to the /tmp directory first! There's more room to play around here than anywhere else in the tomsrtbt ram devices. Of course, you could still create a directory there from root by using: mkdir /tmp/name. Small files can easily be created by doing the following:
1) Enter the command: cat > filename
2) Enter some text on the blank line underneath it. You can add as many lines as you want by pressing the ENTER key after each one...
3) When you are finished, press the ENTER key one more time so there's a completely blank line at the bottom, then press a CTRL key followed by the "D" key before releasing the CTRL key.

Although the command, touch, is often used to create zero-length files under Linux, that command appears to be broken for such purposes in tomsrtbt. No problem, you can still use cat for this purpose as well: Just follow step 1) above and then immediately press the CTRL plus "D" keys to create a zero-length file! Try it out, because we'll be using it in the next session.

In the next session we'll learn how to edit files and read files from a mounted floppy disk!

 

How should I shut down tomsrtbt ?

    Since we've only changed things in your computer's memory so far, the short answer would be: Just turn off the power switch. However, once you start mounting devices, such as a floppy drive, and especially if you are working with a Linux installation on a hard disk, you must always make sure that data is flushed (written) to any writeable devices, then umount (un-mount) them and shut down the file system itself in the proper sequence. Many Linux installations have programs that take care of all these things for you, but don't assume that unless you've checked. You can begin practicing correct shut down habits by using the command: halt (or  poweroff ; they do the same thing under tomsrtbt) to end your tomsrtbt sessions! You can even reboot your machine with: reboot which uses the same binary file as halt. On a full Linux install, I suggest using: shutdown now and observe what happens, followed by halt (the command poweroff exists on full Linux installations as well). Here's an example of what you might see under tomsrtbt :

The Facts about ls and color :
If you look up the "man page" for ls, you'll find that the listed items are only supposed to be colorized if you add the option "-- color=" (either auto or always) on the command line. So, why are we seeing color in tomsrtbt without that option? The reason is because Tom defined ls as a function in his /etc/profile  file as follows:

ls () { /usr/bin/ls --color=auto "$@";}

this means that anyone using ls at a prompt will have the option "--color=auto" applied every time; the "$@" simply means that whatever else was entered after ls on the same line, should also be passed along to the real
ls command program at /usr/bin/ls. This profile file in the /etc
directory is 'exectued' by tomsrtbt ash shell every time you login to one of the four consoles.
    On most Linux distributions, if color isn't always active, you can use a command called alias inside of a configuration file, rather than doing what Tom did above. Each user often has their own "bashrc" file in which you could enter a line such as:
alias ll='ls -l --color=tty' and simply enter 'll' at the prompts.

More Help for the Curious:

Enter the commands:   man ls  and  man cat and skim the files, noting what you've already learned about these commands. Read other "manual pages" as your curiosity gets the better of you; or better yet, you can review a list of all the commands and files that are documented in tomsrtbt by entering: ls /usr/man at any prompt. Sometimes these 'help' pages won't be much help at all, and may contain information that doesn't specifically apply to tomsrtbt (but will be useful to Network Administrators and/or be found on systems with a full Linux install).
[ NOTE: In tomsrtbt, the man pages are nothing more than text files, but it's the only single diskette distribution of Linux I know of that even bothers to include documentation like this! Under a full Linux install, man pages will make use of bold (or colored) text and have a special format that requires a real man program to read them. The man on Tom's diskette is just a very short script:  more /usr/man/$1  ]

 

Next Session:

Using the "vi" Text Editor and Mounting

 

Last Updated: 25 JAN 2003.


 

The Starman's Index Page