Terminal exploration in home directory Debian Wheezy 7

Terminal exploration in home directory Debian Wheezy 7

It’s time to guide us through the system using Terminal. We can see the same folder structure as we have seen it in the graphical user interface.

Let’s take a tour.
Click on applications and highlight Accessories. Go to Terminal and open it.
On a fresh installed Debian system you will see a white window with text displayed anne@alfa:~$.

In this example is anne a default user.
anne        username who is logged on the system.
@alfa:     computername.
~$            Path: /home/anne.
Our prompt looks like this.

anne@alfa:~$

If we need high priveleges on the system we can login as root (administrator).
The root user can install, modify, change ownership, configure permissions, etc….
We can use the su or sudo command. When we use su you will logged as administrator until you execute the exit command.
Sudo is used for one action, no need to stay administrator after the task has ended. Example: sudo apt-get install……….

Type su and enter.
Type root user password and press enter.
Now we are logged as root user. Pay attention, we’re able to mess up the system ;-).
Notice the working directory.

anne@alfa:~$ su
Password:
root@alfa: /home/anne#

If you doubt who you are we can use the command whoami.
Type whoami and enter.
We can see at the prompt who is logged,
#
  root user

$  default user

anne@alfa:~$ su
Password:
root@alfa: /home/anne#  whoami
root
root@alfa: /home/anne#

We can discover who is logged.
execute the command who and enter.
Notice, you don’t see the root user.

anne@alfa:~$ su
Password:
root@alfa: /home/anne#  whoami
root
root@alfa: /home/anne# who
anne      tty7                         2013-10-25  09:54  (: 0)
anne      pts/ 0                      2013-10-25  09:54  (: 0. 0)
root@alfa: /home/anne#

Let’s go back and use our default user.
type exit and enter.
Our prompt is $ again.
Look what we will see when you execute who.
Who is logged in? The same users as we executed the command while we were root.
The root user runs on the background and is never displayed when you execute who.

anne@alfa:~$ su
Password:
root@alfa: /home/anne#  whoami
root
root@alfa: /home/anne# who
anne      tty7                         2013-10-25  09:54  (: 0)
anne      pts/ 0                      2013-10-25  09:54  (: 0. 0)
root@alfa: /home/anne# exit
exit
anne@alfa:~$ who
anne      tty7                         2013-10-25  09:54  (: 0)
anne      pts/ 0                      2013-10-25  09:54  (: 0. 0)
anne@alfa:~$

When we start the terminal the user default location is the home folder. The home directory can contain many users.
Sometimes it’s difficult to see where you’re working in. To solve this you can execute the pwd command.
Type pwd and enter. (print working directory).
/home/anne is the current working directory.

Wat’s in the box, you can use the command ls to look in your home folder.
Type ls and enter. ( list directory contents).
The ls command will display the contents of the home folder: Desktop, Documents, Downloads, Music, Pictures, Public, Templates and Videos.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop   Documents   Downloads   Music   Pictures   Public   Templates   Videos
anne@alfa:~$

We want to known who have created the folders and what the permissions are.
To do that we can execute the command ls -l.
Type ls -l( list directory contents) -l ( list one file per line)
The ls -l command will display the contents one file or directory per line.

In this example all directories displayed in an longer format.
d  directory
    file
   symbolic link
rwxr-xr-x  read, write, execute, read, none, execute, read, none, execute
2   ..link parent folder / . directory itself
anne anne  owner, group
4096  size directory
oct 17 16:25  last modifica;tion directory
Desktop, Documents, etc…   Directory

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop   Documentens   Downloads   Music   Pictures   Public   Templates   Videos
anne@alfa:~$ ls -l
total  32
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Desktop
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Documents
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Downloads
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Music
drwxr-xr-x 2 anne anne 4096  Oct  17  23:07  Pictures
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Public
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Templates
drwxr-xr-x 2 anne anne 4096  Oct  17  16:25  Videos
anne@alfa:~$

We can see even more than this. Show hidden directories and files in our home folder.
ls -l( list directory contents) -l ( list one file per line) -a ( do not ignore entries starting with .).
The ls -al command will display the contents one file or directory per line even the hidden ones.
Type ls -l and enter.

A dot before represents a hidden directory or file.
In this example:       .bash_history, .bash_logout are hidden files.
                                   .cache, .config are hidden directories.
We are able to see the contents of hidden directories and files.

type ls .local and enter.
The content of the hidden .local directory is share. The directory share isn’t hidden.

debian_64Bits-8


Sometimes we need to clean the screen in terminal, press ctrl+l or type clear screen and enter.
Your terminal looks like at the beginning.
Our working directory is /home/anne and the contents of it is:

Desktop, Documents, Downloads, Music, Pictures, Public, Templates and Videos.

anne@alfa:~$
anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop   Documentens   Downloads   Music   Pictures   Public   Templates   Videos
anne@alfa:~$

Let’s change the working directory to Documents.
Use cd + name directory you prefere command (change directory) Pay attention, it’s capital sensitive. Try and see what happens.
Type cd documents and enter.
bash: cd: documents: No such file or directory
This is faulty so let’s do it the right way.
Type cd Documents and enter.

Our working directory is now Documents.

anne@alfa:~$
anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop   Documentens   Downloads   Music   Pictures   Public   Templates   Videos
anne@alfa:~$ cd documents
bash: cd: documents: No such file or directory
anne@alfa:~$ cd Documents
anne@alfa:~$ ~/Documents$

We have different ways to navigate through our folder structure.
Our task is to go back in your home folder.
Change your directory by the cd command followed by  ~
Type cd ~
Your active directory is /home/anne

anne@alfa:~$ ~/Documents$ cd ~
anne@alfa:~$

Go back to Documents. type cd Documents + enter.
Execute cd .. and enter. (Leave a space between cd and ..)
You are at your home directory.

anne@alfa:~$ cd Documents
anne@alfa:~$ ~/Documents$ cd ..
anne@alfa:~$

Let’s do it one more time.
Type cd Documents and enter.
Type cd /home/anne and enter.
Now w’re in our home directory.

anne@alfa:~$ cd Documents
anne@alfa:~$ ~/Documents$ cd /home/anne
anne@alfa:~$

here a example how to navigate in your home directory. Play and enjoy it.  😉

debian_64Bits-11

We hope you have enjoyed it.
Next time we will create, modify, move, copy,  change permissions, etc….
Will be continued.

Advertisements

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: