LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
::Linux Guide
::Tips
::Connections
::Alternatives
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: New Users :: Beginners Linux Guide :: Basic Shell Commands


You may have noticed that each time you start Xwindows, a shell window, similar to a DOS window in Win95/98, appears. This is the powerhouse of the Linux OS, and from here you can execute copy, compile, move, find and edit commands just as easily as in dos. Unfortunately, there are different commands used in the Linux shell than in DOS, so I'll explain them one by one. Remember that commands are case sensitive in Linux, so LS is not the same command as ls, and will return an error saying so.

Wiping the screen

To clear a screen full of text, perhaps garbage on a terminal ... just type in clear from the command line

Finding out what is in a directory

DOS has that nice dir command, but where is the Linux version? It's replaced by ls. ls, can be remembered as a list (Acronym) of what is in that directory. It is quite confusing to look at, and its harder to separate what is a folder, what is a file, and what can be run. In DOS, there are a vast number of switched, or options, that can be added to the basic command dir to give more information. Linux is not left behind, and adds even more commands to confuse yourself with *grin*. ls -m (remember this as more), is similar to dir /w, giving horizontal lines of filenames and directory names. ls -l is a switch that will give the full names of the files, and then give the permissions of the files (Who is entitiled to execute them), and whether or not they are executable. If an X is present in the attributes, that file is a program, and can be run by typing ./nameoffile. Files can only be run if they have the ./ prefix before them. The other attributes you will learn as time progresses and you become more familiar with the Operating System. The best usage of ls, is ls --color. This gives a wide listing, with colors assigned to various file types. When using this option, directories are in blue, and executables in green. This option is by far the best. Typing ls --color can get annoying as I found after a while, so its possible to create a text file with 'ls --color' contained, and then allow that file to be executed. By placing this file in the path, and changing its name to lss, you could use it quite frequently! I will show how to do this at a later date.

Changing Directories

Just as in DOS, the cd (Change Directory) command is used. When the command shell opens, it opens in your own, home directory, usually 'root'. If you ever need to return to your own home directory, just enter cd and press return. As in DOS, to move out one level in a directory tree, type cd .. You can go to the root directory of your Linux OS and all it's drives by typing cd /. Note how in Linux, there is a backslash instead of a forward slash. Another thing is that Hard Disks are not mounted as drive c, drive d and so on. They are placed as folders, and to all intents and purposes look just like one big hard disk. To find out what disks are mounted, where, and what capacity they are and have left, type df (I remember this using, disk free, relating to free space). If you want to go to one of the user accounts on your machine, you can cd ~username, and that'll take you to where their account resides (Assuming you have permission to enter their directory). Thats about all that command does.

File name completion

The very nice thing about the Linux shell, as opposed to the DOS shell, is that it can complete file names and directory names for you. The TAB button, located above Caps-Lock, is the completion key. Once you have typed in the beginning of a file, or directory, pressing TAB will search for a list of possible file or directory names. If more than one option is presented, nothing will appear and pressing TAB a second time will present a complete selection of all that are available, enter a few more characters of the option you want, and press TAB again.

Copying files

This is an interesting one. For copying internally between mounted drives, it's very similar to the DOS syntax. to copy blah.xxx from the current directory to /root/, the syntax is cp blah.xxx /root/, just remember that if something is going into a lower level directory to give the full path, including the forward slash.

Moving or Renaming Files

Again, ths syntax is very similar to the DOS syntax. If yout want to rename blah.xxx to xxx.blah, the command is mv blah.xxx xxx.blah, fairly simple. If you are just relocating the file, remember that two files with the same name cannot reside in the same directory, so you will have to give a directory name, just like the description in the Copying section above.

Working with MS-DOS floppy disks

This has to be my favourite shell commandset. Before I learned how to access these properly, I was mounting floppies, and then unmounting them, which was ridiculous. The Mtools that come installed with RH5.x allow file This, as I would say, is gruntling! *grin*.

To get a directory from a DOS floppy, shove it in the drive, and from an RXVT shell, whack in mdir a: - thats all you have to do. It'll list all files with their true DOS names (12345678.123 format), and where possible, give the long filenames too. To copy from a floppy it's just, mcopy a:\nameoffile /anydiryouwant/, simple as that. To copy to a floppy, it's similar, mcopy nameoffile a:\anydirthatexsists. And finally, to delete a file, its just a case of mdel a:\nameoffile.




About the author, Owen Kelly.

USERS COMMENTS


                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell