Home > Computing > Starter UNIX/Linux Commands

Starter UNIX/Linux Commands

So, you’ve set up your VM running Linux (hope it went well!) and you want to do stuff with it. But you don’t know what things mean……

This blog will give you some simple “commands” or instructions to use, and help you find out more about your VM.

So, start up your machine, and get to a usable desktop. When your there you can either right click anywhere on your desktop, or go to the bottom right corner, click on the icon to the right of the red circle, and you have opened a terminal. What this is, is the command line of your VM, its the same as you Graphical User Interface (GUI), but without all the pretty pictures and themes.

Ok, so when you have that done, enter these simple commands, one by one, and press enter after each command (commands are centered, makes for easier reading). Remember, spaces are important: (don’t enter anything in brackets)

date

who am i

id

cal

cal 2010

cal 11 2010

Ok, how’d that work? Good I hope. Next, you need to find out a bit of information about the OS you are working with. Enter :

uname

Then:

uname -sr     (system type, release)

uname -a (all available information)

Next, you’ll want to find out about your processor, so enter

cat /proc/cpuinfo

^ Thats what you should see, of course most of the numbers etc will be different to mine. Most of that stuff is pretty useless to what your doing, so to slim it down to what you want, type in:

cat /proc/cpuinfo | head -8

This bunch of information is much more useful to find out the basics of your system. The vertical line used here is called PIPE, used as a connector between two commands.

The cat /proc/ command is very useful, and can also be used to find out more about your Memory. Enter:

cat /proc/meminfo

Again, you can slim this down by adding:

| head -2

Instead of typing in the command again, press the up arrow on your keyboard, this will bring up the last command entered. Also, when typing a command, if you press TAB, it will auto-fill the command, to what it might be. Its not always right, but its useful.

This gives you the total RAM available, and the total RAM that is free for use.

OK, so information stored on the hard disk, is organised into a file system. You can find out more about the file system by typing:

df

This shows you how much of the disk space is being used…… but most people aren’t interested in that, they are interested in the files and folders containing that information. In a GUI, you see the folders and files as icons. At a command line level, these are called directories. Enter:

pwd (print working directory)

to see what directory you are in. To see what files are in there, type:

ls

or:

ls -a

To move directory, type:

cd (change directory)

To find out more information about a file type:

file filename

To see what permissions you (and others) have to access files, and other information such as size and creation date, enter:

ls -l

So, to make a new directory, make sure you are in your home directory, and type:

mkdir newdir

You can move to newdir by entering:

cd newdir

You can change to the parent directory by giving the command:

cd ..

No matter where you are, your parent directory is always called “..”

Next, enter the following list:

cd

mkdir newdir

cd newdir

touch small.txt

ls -l

What you have done is made a directory, and put a file in that directory, using the touch command. Create the file “empty.txt” in the same directory. To delete a file, the command is

rm

Enter:

rm empty.txt ; ls -l

Now you see that “empty.txt” has been deleted, and that the semi colon (;) allows you to enter more than one command on the same line. Another way of creating a file is using

cat >

Enter:

cat > tiger.txt

There was a young lady from Niger

Who smiled as she rode on a tiger

^D

^D” means “hold ctrl and press D once”. When you ls -l you see the non empty file tiger.txt has been created. To edit the file more, enter:

nano tiger.txt

This is the GNU Text Editor, an easy way to edit the text. Enter the rest of the rest of the Limerick:

They returned from the ride

With the lady inside

and a smile on the face of the Tiger

As you can See on the bottom, all the instructions you need are there.

And finally, to see a list of all of the commands you put in, type:

history

And thats it. Those are some of the basic, useful commands you can use on Linux/UNIX. Of course, if you want to know more of them, look them up, or ask me and I’ll post the links. Hope this was helpful. Keep a watch on here for more to come!

Advertisements
Categories: Computing
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: