A A A
logo2




Listing of the contents of a directory



If you want to list the content of a directory you can use command ls.

owi@laptop:~$ ls

Command ls show only the names of files which are in the working directory. For more information use -l .

owi@laptop:~$ ls -l

Ls –l lists files in 'long format'. It shows a lot of information e.g. who has the right to access, who owns the file, the size of the file in bytes and the time of the last modification


Ls –a shows you all files, even files that are hidden (these files begin with a dot.)

owi@laptop:~$ ls -a

You can merge the flags for example:

owi@laptop:~$ ls -la

You can see all files in a chosen directory (hidden too) and all the information about them.


If you want to list the content of a directory whose name begins with ,for example, with” p” you can use p*. Symbol “*” means an unlimited sequence of signs. Command ls p* lists the content of all directories whose name begins with “p”.

owi@laptop:~$ ls ./m*

There will be a content of all directories whose name begins with” m “in the working directory.

Symbol “*” means one sign.

owi@laptop:~$ ls ./?atematyka

There will be a content of all directories whose names begin with some sign and ends with “atematyka”.



Creating a directory



If you want to make a directory you can use a command mkdir.

owi@laptop:~$ mkdir nazwakatalogu

If you want to make a directory tree you should use flag –p.

owi@laptop:~$ mkdir -p nazwakatalogu/nazwakatalogu2

In the working directory there will be a directory called directoryname1. In it will be a directory called directoryname2.

You can make more directory trees at the same time.

owi@laptop:~$ mkdir -p nazwakatalogu/nazwakatalogu2,nazwakatlogu3/nazwakatalogu4



Removal of a directory



AIf you want to remove an empty directory you can use the command rmdir.

owi@laptop:~$ rmdir nazwakatalogu

WARNING!
If directory isn’t empty you must use command rm –rfto remove it with the content.


owi@laptop:~$ rm -rf nazwakatalogu



Change of a directory



If you want to change a directory you can use command cd .

owi@laptop:~$ cd nazwakatalogu

Command Cd .. changes directory for parent directory.

owi@laptop:~$ cd ..



Copying of a directory



If you want to copy a directory with content you should use command cp –r and additionally use -r. Then you must give a pathname to the directory and, after a space ,a pathname to the place where the directory is supposed to be copied .

owi@laptop:~$ cp -r ~/katalog ./unix



Listing (showing) the current path.



If you want to see the current path you must use a command pwd.

owi@laptop:~$ pwd





Autor: Aleksandra Przybyło
aleksandraprzybylo@gmail.com