とらりもんHOME  Index  Search  Changes  Login

Unix in 30 minutes

Why Unix in 30 minutes?

Perhaps because your boss has told you to learn Unix quickly in 30 minutes. This website helps you!

What is Unix?

It is an operating software (OS). OS is a software which controls a computer and support other softwares to run on the computer. Among many kinds of Unix, nowadays Linux is the most popular.

Why Unix?

Because it is traditional, standard, and useful. Super computers run on Unix. Internet servers run on Unix. Smart phones (Android) run on Unix (Linux). Unix is everywhere.

Why not Windows?

Windows is OK. But Unix (Linux) is sometimes much more useful than Windows (and sometimes Windows is much more useful than Unix).

Why not Mac?

Although many people do not aware, Mac is a Unix.

Launch Unix in your Windows/Macintosh computer now!

First, you should Try Unix immediately. Experience of Unix is much more instructive than just reading a book or websites. For that, you may want to get Unix somehow. Two options:

For Windows user: Install cygwin (it's free!) and launch it!

For Mac user: Find and launch "terminal" on your Mac!

Then you will find "$" mark appearing on a screen. It's a Unix world!

Try commands!

Using your keyboard, type "date" after the "$" mark, and hit the Enter key:

$ date
Thu Aug 25 15:18:16 JST 2016

You will get a response output like above. "date" is an example of "command". Like this, Unix works by commands.

Redirection and a file

Try the following command:

$ date > test

It will not display anything. Don't worry. Then try this:

$ cat test
Thu Aug 25 15:25:20 JST 2016

Now I explain what happened. The "date > test" command gave the result (date info of now) to a file named "test". Then the "cat test" command printed the content of the "test" file. Now you understand that you can switch output of a command to a file by using ">" mark. This important technique is called "redirection". Now you also understand "cat" command. It printouts a content of a file to a screen.

Try the following command:

$ ls -l test
-rw-rw-r-- 1 xxxx xxxx 29 Aug 25 15:55 test

Now you understand that "ls -l filename" command shows info about a file.

Try the following commands:

$ rm test
$ ls -l test
ls: cannot access test: No such file or directory

As you see, "rm" command removes a file.

Directory

"Directory" is a technical word of Unix which is mostly the same as "folder" in Windows. A directory can contain directories and/or files. Try this:

$ ls -l
...
-rw-rw-r-- 1 xxxx xxxx 29 Aug 25 15:55 test
...

The "ls -l" without a filename shows all the files in your directory. Then you try the following commands one by one:

$ ls -l /
$ ls -l /home

Each command will give you different results. You will understand the reason shortly. Try the next commands:

$ ls
$ mkdir test1
$ ls
$ rmdir test1
$ ls

A directory named "test1" will appear after the "mkdir" command and disappear after the "rmdir" command. Now you see the "mkdir" makes a directory and "rmdir" removes a directory.

Try the next commands:

$ mkdir test1
$ mkdir test1/test2
$ mkdir test1/test2/test3
$ ls test1/test2/

Now you understand how the position of a directory (or a file) is described. For example, the position of "test3" is test1/test2/test3, which means "test3 in test2 in test1".

Try the following commands:

$ pwd
$ cd test1
$ pwd
$ cd test2
$ pwd
$ ls

Now you find that "pwd" (present working directory) command tells you in which directory you are working. "cd" (change directory) command let you move from one directory to another.

Pipe

Try the following command:

$ seq 1 1000

This command counts and displays numbers from 1 to 1000. But the head part (1, 2, ...) flows away quickly and you can see only the tail part (..., 999, 1000). Then try this:

$ seq 1 1000 | less

See? By putting "| less", you can stop the display by page. Then try to hit Enter key or space key or arrow key or [page down] [page up] keys. You see that "| less" can control the output. Hit "q" to end it. This "|" mark is called "pipe".

Help and manual and history

Try this:

$ date --help
$ man date

You see, by putting "--help" to a command, you can check a short instruction of the use of the command. "man" command shows a manual (much more detailed info than help) of a command. Hit "q" to end it.

Try this:

$ history

This will show the commands which you have entered so far.

What's next?

You should learn the following commands by yourself:

  • mv ... (move) changes filename. Moves a file or a directory from one directory to another.
  • cp ... (copy) copies a file.

Then start working with Unix. Whenever you encounter a trouble, google about it. Find a bigger tutorial than this website. Good luck!

Last modified:2016/08/29 11:06:07
Keyword(s):
References:[とらりもんHOME]