Linux Examples

From MediaWiki

(Difference between revisions)
Jump to: navigation, search
Line 95: Line 95:
==5. touch command==
==5. touch command==
 +
 +
If you want to make empty file, you can do it with touch command like this:
 +
 +
  [ngrkic@ui ~]$ touch testfile

Revision as of 15:12, 23 March 2011

This page is dedicted to people who wants to get familiar with basic usage of Linux shell. In this exercise will be demonstrated basic of navigating the file system, standard Linux commands, archive tools, data management, basics of bash script language.

Let`s get started:

Contents

1. ls command

List folder:

[ngrkic@ui ~]$ ls /tmp

You will get output simular like this:

007-01-22 people                 misanu
c                                 mpi-start
ce_hist                           node11_hist
course                            phpBB-3.0.8.tar.bz2
Epico.iso                         PPROBAMATLAB
fcub                              PROBAMATLAB
gctest                            realtimeoutput
gctest_main.c                     run_gctest.sh
gctest_mcc_component_data.c       run_gctestsing.sh
gctest.prj                        run_magicsquare.sh
gctestsing                        script.sh
gctestsing_main.c                 simulacija

For more details type :

[ngrkic@ui ~]$ ls -las

You will get output simular like this:


total 1011632
     4 drwx------ 38 ngrkic ngrkic       4096 Mar 22 21:18 .
     4 drwxr-xr-x 94 root   root         4096 Mar 21 10:38 ..
    16 -rw-------  1 ngrkic ngrkic      12482 Mar 23 12:01 .bash_history
     4 -rw-r--r--  1 ngrkic ngrkic         24 Jul 31  2009 .bash_logout
     4 -rw-r--r--  1 ngrkic ngrkic        191 Jul 31  2009 .bash_profile
     4 -rw-r--r--  1 ngrkic ngrkic        124 Jul 31  2009 .bashrc
     0 -rw-rw-r--  1 ngrkic ngrkic          0 Mar 22 21:18 c
     8 -rw-r--r--  1 ngrkic ngrkic       5619 Jul 31  2009 .canna
    20 -rw-r--r--  1 ngrkic ngrkic      20224 May  5  2010 ce_hist
     4 drwx------  3 ngrkic ngrkic       4096 Dec 10 15:47 .config
     4 drwxr-xr-x  8 ngrkic ngrkic       4096 Sep  7  2010 course
     4 drwxrwxr-x  4 ngrkic ngrkic       4096 Dec 10 15:43 .eclipse
     4 -rw-r--r--  1 ngrkic ngrkic        383 Jul 31  2009 .emacs
1008604 -rw-r--r--  1 ngrkic ngrkic 1031798784 Nov 25 16:42 Epico.iso
     4 drwxr-xr-x  5 ngrkic ngrkic       4096 Nov 29  2009 fcub
     4 drwxrwxr-x  3 ngrkic ngrkic       4096 Nov 29 10:06 .felix
   156 -rwxrwxr-x  1 ngrkic ngrkic     155129 Sep 20  2010 gctest
     4 -rw-rw-r--  1 ngrkic ngrkic       3513 Sep 20  2010 gctest_main.c
     8 -rw-rw-r--  1 ngrkic ngrkic       6115 Sep 20  2010 gctest_mcc_component_data.c
    28 -rw-rw-r--  1 ngrkic ngrkic      27854 Sep 20  2010 gctest.prj

2. pwd command

Print name of current/working directory:

[ngrkic@ui ~]$ pwd

You will get something like this:

/home/ngrkic

3. cd command

To change directory to /tmp type :

[ngrkic@ui ~]$ cd /tmp

Then type just cd :

[ngrkic@ui tmp]$ 

Now you are in your home folder (type pwd if you are not sure). If you want to go one folder back type :

[ngrkic@ui ~]$ cd ..

Now you are in system home folder.

When you want to go to root of filesystem, type :

[ngrkic@ui home]$ cd /

Now you are in / folder. If you want you can type ls to see content.

Now return to your home folder by typing :

[ngrkic@ui ~]$ cd

4. mkdir command

When you want to make new folder type next:

[ngrkic@ui ~]$ mkdir testdir

5. touch command

If you want to make empty file, you can do it with touch command like this:

 [ngrkic@ui ~]$ touch testfile
Personal tools