Jump to content
Science Forums

Ubuntu Terminal for nubies.


Recommended Posts

(CRAP!! I forgot I can't change the title!:hihi:)

 

For any one unfamiliar with using a Terminal

the most daunting problem is not knowing how to enter commands and worse not knowing what the commands are can make life in Ubuntu very difficult.

 

While there are package installers which automagicly install most of the goodies the average pc user could want, a great many goodies remain just out of reach for lack of the knowledge needed to install them. Many Debian/Ubuntu/Third party products are not packaged with the familiar point and click installer, this is where the Terminal comes in to play.

 

Meet "Alt F2" Your new best friends, pressing these two yields The Dreaded Terminal.

Below are a few useful commands which I highly recommend printing for a quick reference.

 

File and Directory Commands

 

  • Basic Commands
  • * 3.1. cd

* 3.2. pwd

* 3.3. ls

* 3.4. cp

* 3.5. mv

* 3.6. rm

* 3.7. mkdir

3.1. cd

The cd command

changes directories. When you open a

terminal you will be in your home directory. To move

around the file system you will use

cd. Examples:

To navigate into the root directory, type:

cd /

To navigate to your home directory, type:

cd

or

cd ~

To navigate up one directory level, type:

cd ..

To navigate to the previous directory (or

back), type:

cd -

To navigate through multiple levels of

directory at once, specify the full directory

path that you want to go to. For example, type:

cd /var/www

to go directly to the /www

subdirectory of /var/. As another

example, type:

cd ~/Desktop

 

 

to move you to the Desktop

subdirectory inside your home directory.

3.2. pwd

pwd: The

pwd command will show you which directory you're located in

(pwd stands for “print working directory”). For example, typing

pwd in the Desktop directory, will show ~/Desktop.

GNOME Terminal also

displays this information in the title bar of it's window.

3.3. ls

The ls command shows you the files in your current directory. Used with

certain options, you can see sizes of files, when files where made, and permissions of files. For example, typing

ls ~

will show you the files that are in your home directory.

3.4. cp

The cp command makes a copy of a file for you. For example, type:

cp file foo

to make a exact copy of file and name it foo, but the file file will still be there.

3.5. mv

The mv command moves a file to a different location or will rename a file.

Examples are as follows:

mv file foo will rename the file file to foo.

mv foo ~/Desktop will move the file foo to your Desktop

directory but will not rename it. You must specify a new

file name to rename a file.

If you are using mv with

sudo you will not

be able to use the ~ shortcut, but will have to use

the full pathnames to your files. This is because

when you are working as root, ~ will refer to the

root account's home directory, not your own.

3.6. rm

Use the rm command

to remove or delete a file in your directory. It will not

work on directories which have files in them.

3.7. mkdir

The mkdir command will allow you to create directories. For example, typing:

mkdir music

will create a music directory in the current directory.

 

 

System Information Commands

* Basic Commands

4.1. df

The df command displays filesystem disk space usage for all partitions.

df -h

will give information using megabytes (M) and gigabytes (G)

instead of blocks (-h means "human-readable").

4.2. free

The free command displays

the amount of free and used memory in the system.

free -m

will give the information using megabytes, which is probably most

useful for current computers.

4.3. top

The top command displays

information on your GNU/Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To exit

top, press q.

4.4. uname

The uname command with the -a option, prints allsystem information, including machine name, kernel name & version, and a few other details. Most useful for

checking which kernel you're using.

4.5. lsb_release

The lsb_release command with the -a option prints version information for the Linux release you're running. For example, typing:

lsb_release -a

will give you: No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 7.04

Release: 7.04

Codename: feisty

4.6. ifconfig

The ifconfig command reports on your system's network interfaces.

Executing Commands with Elevated Privileges

* Basic Commands

The following commands will need to be prefaced with the sudo command. Please see RootSudo for information on using sudo.

5.1. Adding a New Group

The addgroup command is used to create a new group on the system. To create a new group, type:

addgroup newgroup

The above command will create a new group called newgroup.

5.2. Adding A New User

The adduser is used to create new users on the system. To create a new user, type:

adduser newuser

The above command will create a new user called newuser.

To assign a password for the new user use the

passwd command: passwd newuser

 

 

Finally, to assign the new user to the new group, type:

adduser newuser newgroup

Options * Basic Commands

The default behavior for a command may usually be modified by adding a --

option to the command. The ls command, for example, has a -s option so that

ls -s will include file sizes in the listing. There is also a -h option to get those sizes

in a "human readable" format.

Options can be grouped in clusters so ls -sh

is exactly the same command as

ls -s -h

Most options have a long version, prefixed with two dashes instead of one, so even

ls --size –human-readable is the same command.

"Man" and getting help * Basic Commands

command --help and man command are the two most important tools at the command line. Virtually all commands understand the -h (or --help) option which will

produce a short usage description of the command and it's options, then exit back to the command prompt. Type

man -h or man –help to see this in action.

Every command and nearly every application in Linux will have a man (manual) file, so finding them is as simple as typing man command to bring up a longer manual entry for the specified command. For example,

man mv will bring up the mv (move) manual.

Move up and down the man file with the arrow keys, and quit back to the command prompt with q.

man man will bring up the manual entry for the man command, which is a good

place to start.

man intro

is especially useful - it displays the "Introduction to user commands" which is a well-written, fairly brief introduction to the Linux command line.

There are also info pages, which are generally more in-depth than man pages. Try

info info for the introduction to info pages.

7.1. Searching for man files

If you aren't sure which command or application you need to use, you can try searching the man files.

man -k foo, will search the man files for foo. Try

man -k nautilus to see how this works.

This is the same as the apropos command.

man -f foo, searches only the titles of your system's man files. For example, try

man -f gnome

This is the same as the whatis command.

(CRAP!! I forgot I can't change the title!:doh::doh::turtle::doh:)
Link to comment
Share on other sites

SCHWEET! much appreciated:)

 

Input would also greatly appreciated;) (nifty tricks with instructions, handy modifiers, etc.) I guess I should mention somewhere here that I'm still learning how to use the Terminal myself. (I don't want anybody thinking I'm an expert or something.)

 

 

One other thing....

If anyone out there knows of a dictionary of terminology for Ubu./Debian based OS text commands, symbols, etc. and their use. A link would be greatly appreciated.

Link to comment
Share on other sites

You're not logged in as root, are you?

 

Don't operate the computer as the superuser. You should only become the superuser when absolutely necessary. Doing otherwise is dangerous, stupid, and in poor taste. Create a user account for yourself now!- From the link provided by Freezy above.

Yup! I've already learned the hard way!;) ( :) )

 

Thanks again Freezy for the link:) I Really really wish I had known about it when I first started using Ubu.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...