FreeOS.com logo

FreeOS Most Popular
* Most Read stories
* Commented Stories
* Active Categories
* Non Linux Section
* User Submitters
* Top Polls
* Top Authors
* Top Reviews
* Top Rated
* Top Search Terms

Top Articles
* Writing a Linux device driver
* The Linux filesystem explained
* Samba NT Domain Controller
* Setting up Squid as your caching HTTP/FTP proxy
* Web server tutorial - Part 1

FreeOS Highlights
* Howtos (72)
* Reviews (20)
* Opinions (18)
* Interviews (8)
* News (3)

My FreeOS

Nick:
Pass:
Register

Forgot your password?

Contact Us
Contact Us

       

Project: Linux triangle Howtos triangle

Starters for Linux - Part 1

By Trevor Warren <trevor@freeos.com>
Posted: ( 2001-01-26 05:03:17 EST by )

This series of articles aims at helping novices get a firm grip on the basics of
Linux. It’s for those of you keen to get up and running with Linux, but don’t know where to start. In this first part of the series, we shall look at using Linux via its Command Line Interface or CLI.

Starters for Linux - Part 1

Among our wonderful readers we bet there are some of you who would like to get to know a lot more about Linux but have nowhere to go or should we say, just too confused as to where to start. This series aim at helping you novices get a firm grip on the basics of Linux.

We believe that Linux is more than just an Operating System. It’s a movement to free the world from the shackles of third grade Commercial software. Linux is an extremely vast topic and it would not be possible for us deal with each and every aspect of it. We would therefore be sticking to the general aspects that would interest the average user.

Dealing with Linux consists of dealing with a whole gamut of issues, right from
Installing the Operating System, getting services up and running, installing the software of your choice, dealing with package managers, window managers, desktop environments, configuring the graphics environment to configuring your machine to connect to the Internet, configuring your machine to check mail and a whole lot of other tasks that you would like to perform with the same ease of use as you do on your existing Operating System.

Linux to owes it alliance to the Open Source community and to the legacy of the Unix Operating System. Linux has imbibed several aspects of various Unix systems that exist today. Most die hard open source fans however would argue, and so do we, Linux isn’t Unix. Though we would love to talk at length about the origins of Linux, it isn’t relevant in this article. So, in this few next paragraphs we would like to take the opportunity to introduce you to the various facets of Linux.

If you have worked or even seen other Unixes out there, one thing that immediately comes to your minds is perhaps the dark murky depth of the ocean? The scary black screen and the command line with strange white text flowing across? Give us an opportunity to lay your fears at rest. Of course the CLI (Command Line Driven Interface) is a popular method of interacting with your Linux box, but believe me, Linux comes with a very capable GUI. In fact due to the sheer customisability of the Linux GUI, it is extremely easy and fun to use…not like some other operating systems you might have encountered!

The Linux CLI however remains an extremely efficient alternative to the GUI and can often be a faster and more powerful method to move around your Linux system. For the first part of this series we shall look at using Linux the CLI way. Before we begin this epic odyssey, we would recommend you check out a previously published article at http://www.freeos.com/articles/3214/ that documents a few tips and tricks for Linux.

Using Linux the CLI way --Basic Operations on Linux

Lets start with commands that deal with Basic Operations on Linux.
Linux like any other Unix system is case sensitive so type the commands mentioned in exactly the same way as they are written in this article.

The File Separator
An important feature that differentiates Unix systems from Windows systems is the way one refers to the File Separator. On UNIX based systems it’s as follows.

/usr/local/apache/httpd.conf -----> the forward file separator.

While on Windows systems.
C:webserverapachehttpd.conf -----> the backward file separator.

any_command --help | more
Display a brief help file on a command (works with most commands). –help works similar to DOS /h switch. The more pipe is needed if the output is longer than one screen.

|
This isn’t an L, it is what we call the redirection operator. If you are trying to find it on your keyboard, you’ll probably see it on the top row with the numerical keys. The main purpose of the redirector is to redirect output from one process to another. It works at the shell level and is very handy to have around. More on this later.

ls
Lists the content of the current directory. Under Linux, the command dir is an alias to ls. Many users have ls to be an alias to ls --color.

ls -al | more
List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the more command, so that the display pauses after each screen fill.

cd /path_to_directory
Change directory. cd - will take you to your previous directory and is a convenient way to toggle between two directories.

cp /path_to_copy_form /path_to_copy_to
Copy files from source to destination.

mv source destination
Move or rename files. The same command is used for moving and renaming files and directories.

ln source destination
Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it.. Any changes in the file are automatically visible throughout. When one directory entry is removed, the others stay intact. The limitation of the hard links is that the files have to be on the same file system. Hard links to directories or special files are impossible.

ln -s source destination
Create a symbolic (soft) link called destination to the file called source. The symbolic link just specifies a path where to look for the file. In contradistinction to hard links, the source and destination do not have to be on the same file system. In comparison to the hard links, the drawback of symbolic links is that if the original file is removed, the link is broken, symbolic links can also create circular references (like circular references in spreadsheets or databases, ( e.g., a points to b and b points back to a).

rm files
Remove (delete) files. You must own the file in order to be able to remove it.

mkdir directory
Make a new directory.

rmdir directory
Remove an empty directory.

rm -r files
(Recursive remove) Remove files, directories, and their subdirectories.
Be careful with this command when logged in as root--you can easily remove all files on the system if you are not careful.

cat filename | more

View the contents of a text file called filename, one page a time. The | is the pipe symbol (on many keyboards it shares the key with) The pipe makes the output stop after each screenful. For long files, it is sometimes convenient to use the commands head and tail that display just the beginning and the end of the file. If you happened to use cat on a binary file and your terminal displays funny characters afterwards, you can restore it with the command reset.

less filename
Scroll through a content of a text file. Press q when done. Less is roughly equivalent to more, the command you just read about.

pico filename
Edit a text file using the simple and standard text editor called pico.

pico -w filename
Edit a text file, while disabling the long line wrap. Handy for editing configuration files. e.g. /etc/fstab. We would advise you to disable the word wrap feature for the simple reason that you could very easily mess up the configuration files with Word Wrap on, because the line length will differ from system to system.

lynx file.html
View an html file or browse the net from text mode.

tar -xvzf filename.tar.gz
Untar a tarred and compressed tarball (*.tar.gz or *.tgz) that you downloaded from the Internet.

tar -xvf filename.tar
Untar a tarred but uncompressed tarball (*.tar).

gunzip filename.gz
Decompress a zipped file (*.gz or *.z). Use gzip (also zip or compress) if you want to compress files.

bunzip2 filename.bz2
Decompress a file (*.bz2) zipped with bzip2 compression utility. Used for big files.

unzip filename.zip
Decompress a file (*.zip) zipped with a compression utility compatible with PKZIP for DOS.

find / -name filename
Find the file called filename on your file system starting the search from the root directory / . The filename may contain wildcards (*,?).

locate filename
Find the file name of which contains the string filename. Easier and faster than the previous command but depends on a database that normally rebuilds at night.

pine
A good text-mode mail reader. Pine will let you read the local mail, e.g. the mail you get from a computer on your home network.

talk username1
Talk to another user currently logged on your machine (or use talk username1@machinename to talk to a user on a different computer). To accept the invitation to the conversation, type the command talk username2. If somebody is trying to talk to you and it disrupts your work, your may use the command mesg n to refuse accepting messages. You may want to use who or rwho to determine the users who are currently logged-in.

mc
Launch the Midnight Commander file manager (looks like Norton Commander) for Linux.

telnet server
Connect to another machine using the TELNET protocol. Use a remote machine name or IP address. You will be prompted for your login name and password--you must have an account on the remote machine to login. Telnet will connect you to another machine and let you operate on it as if you were sitting at its keyboard (almost). Telnet is not very secure--everything you type goes in open text, even your password!.

rlogin server
(Rremote login) Connect to another machine. The login name/password from your current session is used; if it fails you are prompted for a password.

rsh server (remote shell)
Yet another way to connect to a remote machine. The login name/password from your current session is used; if it fails you are prompted for a password.

ftp server
Ftp another machine. (There is also ncftp which adds extra features and gftp for GUI .) Ftp is good for copying files to/from a remote machine. Try user anonymous if you don’t have an account on the remote server.

The essential ftp commands are:
ls (see the files on the remote system), ASCII, binary (set the file transfer mode to either text or binary, it is important that you select the proper one ),

get (copy a file from the remote system to the local system),

mget (get many files at once), put (copy a file from the local system to the remote system),

mput (put many files at once), bye (disconnect).

For automation in a script, you may want to use ncftpput and ncftpget, for example:
ncftpput -u my_user_name -p my_password -a remote.host.domain remote_dir *local.html

minicom
Minicom program. It’s a communication program that somewhat resembles the famous old DOS communication program, Telix. You could always use your existing shell accounts via minicom.

/program_name
Run an executable in the current directory, which is not on your PATH

xinit
Start a barebone X-windows server (without a window manager).

startx
Start an X-windows server and the default window manager. Works like typing win under DOS with Win3.1

startx -- :1
Start another X-windows session on the display 1 (the default is opened on display 0). You can have several GUI terminals running concurrently. Switch between them using Ctrl+Alt+F7, Ctrl+Alt+F8, etc.

xterm (an X terminal)
Run a simple X-windows terminal. Typing exit will close it.

shutdown -h
Shut down the system to a halt. Mostly used for a remote shutdown. Allowed only when logged in as root. Use Ctrl+Alt+Del for a shutdown at the console (which can be done by any user).

halt
Halt the machine. Used for remote shutdown, simpler to type than the previous command.

man topic
Display the contents of the system manual pages (help) on the topic. Try man man first. Press q to quit the viewer. The command info works in a similar fashion and may contain more up-to-date information. Manual pages can sometimes be hard to read.

--help

Brings up a short, easy to digest help on a command. If you need more info, go to the directory /usr/doc and look for the command.

So that was the list of the various commands that we thought were essential for any user to carry out basic operations on a Linux/Unix machine. Next, we will carry an article on a whole lot of important commands on handling System processes and Basic System Administration.

Other articles by Trevor Warren

Current Rating: [ 7.63 / 10 ] Number of Times Rated: [ 90 ]

More Howtos
* Kernel Compilation & Avoiding ‘Unresolved Symbol’
* Configuring CVS and CVSUP on Linux
* Knoppix installation tips
* Maximum Mount
* A WebServer Guide -- Help Using Apache

Contents
Articles
  Howtos
  Interviews
  News
  Opinions
  Reviews
Comparison
Links
  Articles
  Howtos
  Interviews
  Opinions
  Reviews
  Websites
News

Linux
About Linux

Print It!
Printer Friendly Version