Tuesday, September 2, 2008

The Linux Terminal For Beginners

source:

http://davestechsupport.com/blog/2008/06/14/the-linux-terminal-for-beginners/

A very long time ago, computers didn’t have mice, icons or fancy graphics. Instead of an Operating System with a Graphical User Interface, there was the Command Line Interface. With it, you would issue commands to your computer in a text only environment that is not seen so often these days. But many computer technicians, especially Linux geeks, consider it to be one of the best ways to interact with the PC for certain kinds of tasks. Though there is a little bit of a learning curve about it new users shy away from . So I’m going to try and flatten that curve with an introduction to the Terminal window for beginners.

Understanding the Command Line

To help get a better feel for the Terminal, you should open one up right now and follow along with this guide. To do this (in Ubuntu) click Applications>Accessories>Terminal. Once you do, a new window will appear with a command prompt and a blinking cursor. The prompt typically looks like this:

username@hostname:~$

The username is your username, the hostname is the name of your computer. The tilde symbol “~” is shorthand for “your home folder”. And the dollar sign indicates that you are currently operating under a kind of limited privilege mode (if you were running terminal with Root level privileges, the $ would be a #. More on that later). Following all of these things is a blinking cursor, which is your cue to begin typing a command into the Terminal window.

In the above screenshot, we have our Nautilus file manager to the left as well as a small terminal window on top of it where I’ve typed in the commands “cd Documents”, followed by an “ls” command, pressing Enter after each. If you’ll notice, the “dear ubuntu forum moderators.odt” file is shown in both the terminal window as well as the file browser. It’s the exact same file, and I used those two commands in Terminal to “browse” to the folder containing that file and list the contents of the folder. So we have two commands here that we can talk about briefly:

cd - Change Directory (e.g., “cd Documents”)
ls - List current folder contents.

When you first start Terminal, you are usually placed in your Home Folder (which is indicated by the ~ (tilde) symbol). If you type ls and press enter, you’ll see all of the files and folder contained in your Home Folder. Try to practice navigating from your home folder to some other folder using the cd command. NOTE: All Linux commands are Case-Sensitive! Once you’ve navigated into a folder, or perhaps into a folder within another folder, you can go “backwards” to the parent directory by typing “cd ..”

Exercise 1: cd and ls

  1. Click Applications>Accessories>Terminal
  2. Type ls to view the contents of your Home Folder
  3. Type cd Documents and press Enter to navigate into the Documents folder.
  4. Type ls to see the files (if you have any) listed. Then type cd .. and press enter to return to your home folder.

Ok, how about a few more commands?

As shown above, the cat command can be used to create new files, but it can also be used to append text from one or more files to the end of another file… but we’re not going to get that advanced. We just want to create a new file and play with it using other terminal commands.

cat - Create new files, combine text files and display them
cp - Copy
rm - Delete/Remove

Using these commands, we’re going to create a text file, copy it, then delete the first copy.

Exercise 2: cat, cp and rm

  1. Open terminal, and browse to the Documents folder by typing cd Documents, and press Enter
  2. Create a new text file by typing cat > foo.txt and press Enter.
  3. You’ll be sent to a blank line just below the command prompt. You can type whatever you want, starting a new line each time you hit Enter. It’s a basic text editor. When you’re finished typing, you can save and exit by pressing CTRL-D.
  4. Type ls to see the new file in the directory. To display it’s contents, you can type cat foo.txt.
  5. Copy the file by typing cp foo.txt foo2.txt. Type ls again to see the new second file.
  6. Delete the first file by typing rm foo.txt, and then type ls again to see the change you made.

There are other commands out there besides cat (such as touch) that can be used to create new files, but we’re trying to keep this short and simple.

Now lets create a file, then a new folder, and move the file into that folder. We’ll do this with the mkdir, mv and ./ commands. The ./ command in particular is interesting — it basically stands for “the current directory you are in”. Sound redundant, right? Here’s why you need to use it: There are many commands in the Linux system that can be run from any directory, such as the ones we’ve been using (cat is an example). These commands reside in a location of the computer that’s been designated to be available at the terminal no matter what folder you reside in.

So say you created a computer program called “cat”, but had nothing to do with text files, and more to do with the feline animal. If you simply typed “cat”, Linux would assume you meant the cat program we used to create a text file, and not yours. By adding the ./ in front, it forces Linux to focus on that local folder you happen to be in.

Exercise 3: mkdir, mv and the ./ delimiter

  1. Open terminal, and cd into you Documents folder.
  2. Type cat > foo2.txt, press enter, type some text, then CTRL-D to save and exit cat.
  3. Type mkdir foocopyfolder to create a new folder. You can type ls after this to see it.
  4. Type mv foo2.txt ./foocopyfolder/ to move the file into foocopyfolder
  5. Type ls to see that the file is now missing, then cd foocopyfolder, and then ls one more time to see the recently moved file.

Other Useful Commands

By now, you should already be familiar with the basics of the terminal. Here are some other commands you can experiment with:

rmdir - Remove Directory
sudo - This is typically inserted in front of any regular command that requires root level privileges in order to do. You can think “Super User Do” to help you remember how it’s spelled and what it does. For example, if you wanted to execute a command that required root privilages (such as installing a program) you would type “sudo apt-get install vlc”. Remember, the terminal windows is Case-Sensitive.
locate - a useful index-based file search utility
lspci - Lists PCI devices in your computer (used for technical troubleshooting)
lsusb - Similar to lspci, but for USB devices
apt-get - This is used very often to install, remove and update software. An example of this command would look like: sudo apt-get install vncviewer. Note the sudo in front.

The Manual Command

Now, a lot more could be said about these commands. If you ever want to read all you can read about any one command, you can do that with the man command (which is short for Manual), followed by the command you’re interested in reading about. For example, if I wanted to read about all the different options for the ls command, I would type man ls. When viewing a manual for a command in terminal, you can use the up and down arrows to scroll, and then when you’re done reading, you need to press the Colon key : followed by the q key. This will take you back to the Terminal window.

That’s all I am going to write about the Terminal for today. The three very simple exercises above should have you feeling just a little more comfortable with the Terminal and navigating around your file system. Here are a couple tips though, in case you get lost:

cd / - takes you to your root directory
cd ~/ - takes you to your Home Folder.

And just so you know, your Home Folder is actually located in /home/yourusername/.

There are a lot of great guides out there that go into a lot more detail that I’m willing to do here, so check Google to see what you can find. Here’s one that I think is pretty clear and concise that you should take a look at if you intend to learn more about the command line.

Do stuff in Ubuntu without touching the mouse

If you want to run an application, just hit Alt + F2 and then type the name of the program. If it needs to run with root privileges, just type gksu beforehand. For example, to run GNOME Terminal, you would type terminal. To run Gedit, type gedit. If the program is command line, check the Run In Terminal box (use the Tab key to move from field to field in the dialog box and hit the Space to select a field). This will then open a terminal window and run the command, but be aware that the terminal window will then close as soon as the command has finished, so you won’t be able to inspect the output. Want to browse to a file system location, but too lazy to grab the mouse and click the Places menu? Hit the forward slash (/), and then type the path into the dialog box that appears. Want to rename a file but don’t want to use the mouse? Just ensure the file is highlighted (use the cursor keys to highlight it if necessary) and hit F2. Then type the new filename. To change the file extension too (which isn’t highlighted for deletion by default), just hit Ctrl + a and then type the complete new filename.

source: http://www.ubuntukungfu.org/blog/2008/07/10-things-you-didnt-know-you-could-do-in-ubuntu/

Sunday, August 31, 2008

Friday, August 29, 2008

Calibrate Monitor in Linux



Are your fonts and windows not as sharp and clear as you would like and too bright and still no direct hardware monitor changes effective?
Gammapage is a nice python tool to calibrate your monitor:
http://www.pcbypaul.com/software/GAMMApage.html

Calibration Tool for your monitor on Linux


Nice Python tool to calibrate your monitor: Gammapage


http://www.pcbypaul.com/software/GAMMApage.html

You also can use xgamma for doing this at startup:
Go to System. Preferences, Sessions.
Choose Add
name: xgamma;
command:
xgamma -gamma 0.86


This is of course a choice you have made earlier for example with the tool Gammapage.
Now every time on startup your gamma will be reset by xgamma.

Tuesday, August 26, 2008

Connecting Ubuntu Pc two way with Windows Workgroup pc's

Step 1 - Install Ubuntu 8.04

source: http://www.europe.eclipse.co.uk/Ubuntu/804%20on%20Win%20Network.htm

After a basic install while connected to your pre-existing Windows network, internet access from the Ubuntu PC should work straight away.

Internet access by the Ubuntu PC is essential to this process. Do not proceed unless it is working.

By default, a lot of networking capability on the Ubuntu machine is already working:

In Places > Network, you will see the 'Windows Network' icon.

D/clicking on it will take you to [the name of your windows network], in my case mshome

D/clicking on mshome will display all the pc's currently on your network within the mshome workgroup.

D/clicking on the icon of a pc will display it’s shared folders.

D/clicking on a Windows shared folder will cause an ‘Enter Password’ dialog to appear.

Just click on ‘Cancel’, and the dialog will close, and the contents of the folder will be displayed anyway.

Also, a shortcut to the Windows shared folder will appear on the Ubuntu desktop.

This shortcut will be removed automatically at the next reboot, or it can removed by right-clicking on it & selecting ‘Unmount Volume’

So, by default, from your Ubuntu PC you can transfer files between the Ubuntu Desktop (and other folders) & Windows Shared folders

However, the Ubuntu pc cannot be seen from the Windows pc's.

The rest of this guide shows how to make the Ubuntu pc visible to & accessible by the Windows pc’s on your home network.

===========================================================================

Step 2 - Create a folder in Ubuntu to become visible (later) on the network

You could think of this new folder becoming your Ubuntu equivalent of the 'Shared Documents' folder in Windows.

Right-click on the Ubuntu desktop & create the new folder called, say, 804Shared

===========================================================================

Step 3 - Prepare the folder for sharing on the network

Right-click on the 804Shared folder, and select Sharing Options

A dialog saying Folder Sharing will appear. Select the Share this Folder’ box

After a short delay, a dialog saying' Sharing Service is not installed' will appear.

Click on Install Service Ubuntu will ask for your login password

This will cause a program called Samba to be downloaded from the internet & installed

Wait for the installation to complete with the message Changes Applied, then close the dialog.

NOW REBOOT THE UBUNTU PC – I know you shouldn’t have to, but I have found this to be essential on some installations, so why not….

Right-click on the 804Shared folder, and select Sharing Options

The dialog saying Folder Sharing will re-appear, with more options now available:

Select the ‘Allow other people to write in this folder’ box

Click on Create Share.

A dialog ‘Nautilus needs to add some permissions…..’ appears.

Click on ‘Add the permissions automatically’

The icon for the shared folder will now change to indicate sharing by displaying a double arrow:

At this point, the Ubuntu PC will become visible to Windows PCs on the network:

===========================================================================

Step 4 - Access the Ubuntu pc from a Windows pc.

On a Windows XP PC, go to 'My Network Places' > 'View Workgroup Computers'

The Ubuntu PC icon will be shown, and when clicking on it a password is requested.

Enter the login name & password of the Ubuntu PC you are connecting to:

You can then see & access the Ubuntu shared folder you created in step 2. Job done!

Blog Archive