Users, Groups and their permissions, Debian Wheezy 7.2.

Users, Groups and their permissions, Debian Wheezy 7.2.

In this tutorial we’ll talk about users, groups and their permissions on files and directories.
We’ll guide you how to add users and make them members of groups.
At this point we’ve only one default user installed.
Let’s see wich user is active by using whoami commando.
Type whoami + enter.
We see user “anne” is logged into our system.

anne@alfa:~$ whoami
anne
anne@alfa:~$

You can use who commando to see all users on your system.
We didn’t execute that but we used users commando instead of who.
Type users + enter.

anne@alfa:~$ users
anne anne
anne@alfa:~$

Our output displays “anne” twice.
Our Debian Wheezy system handles different kinds of users and groups.
The first “anne” is the user itself (owner) and the second “anne” correspond her primary group membership.
Users can be member of primary and supplementary groups.
This will be discussed later on.
Short description of the characters u.g.o.a. used on our Debian Wheezy systeem.
u = user (owner)
g = group (group which user belongs to)
o = other (everyone who logged local or on a remote machine)
a = All users belonging to u,g and o.

Each file or directory created by the user “anne” becomes her property and she’ll have read, write and execute permission in her /home/anne directory.
The primary group “anne” and the “others” (everyone) have read and execute rights on the folders and subdirectories owned by anne.
Take in account that all users belonging to others can read the contents of the /home/anne directory.
This is in fact a security breach and it must be taken care off.
How to do that will be discussed later on.
Luckily nobody have write permission on /home/anne except “anne” and user “root”.
Let’s take a closer look at our permissions in the home directory of “anne”.
Type ls -l + enter.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls -l
total 32
drwxr-xr-x 3 anne anne 4096 Nov  4 16:09 Desktop
drwxr-xr-x 3 anne anne 4096 Dec  1 14:51 Documents
drwxr-xr-x 2 anne anne 4096 Nov 16 20:18 Downloads
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Music
drwxr-xr-x 2 anne anne 4096 Dec  7 13:05 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’ll explain our output displayed above.
d = directory
l = link (not displayed in this output)
– = file (not displayed in this output)
rwx = read, write, execute permission user anne
r-w = read, execute permission primary group anne
r-w = read, execute permission others (everyone)
3 = number of available links to directory
anne = user (owner)
anne = primary group anne which user anne belongs to
4096 = size of the direcoty in bytes
Nov = month of last modification directory
4 = date of last modification directory
16:09 = time stamp last modification directory
Desktop = name of the directory

Let’s examine our directory root /.
De root directory is the home directory owned by the user root.
The user root has full permission over the whole system even not owned folders and files.
The users which belongs to the primary group ‘root’ and ‘others’ are permitted to read and execute.
This mean everyone can read those directories but they aren’t able to write.
It’s nice to explore those directories who has learning purposes.
Our system is a free examine “place” to explore and having fun.
In a company environment can this affect the security purposes.
We’ll discus this later on.
Typ cd / + enter and than type ls -l + enter.

anne@alfa:~$ cd /
anne@alfa:/$ ls -l
total 88
drwxr-xr-x   2 root root  4096 Oct 17 16:12 bin
drwxr-xr-x   3 root root  4096 Oct 17 16:16 boot
drwxr-xr-x  14 root root  3160 Jan  9 17:59 dev
drwxr-xr-x 133 root root 12288 Jan  9 17:59 etc
drwxr-xr-x   3 root root  4096 Oct 17 16:18 home
lrwxrwxrwx   1 root root    30 Oct 17 15:47 initrd.img -> /boot/initrd.img-3.2.0-4-amd64
drwxr-xr-x  16 root root  4096 Oct 17 16:12 lib
drwxr-xr-x   2 root root  4096 Oct 17 15:46 lib64
drwx——   2 root root 16384 Oct 17 15:45 lost+found
drwxr-xr-x   4 root root  4096 Oct 25 11:57 media
drwxr-xr-x   2 root root  4096 Sep 23 00:31 mnt
drwxr-xr-x   2 root root  4096 Oct 17 15:46 opt
dr-xr-xr-x 135 root root     0 Jan  9 17:59 proc
drwx——   9 root root  4096 Dec 12 17:35 root
drwxr-xr-x  19 root root   840 Jan  9 18:03 run
drwxr-xr-x   2 root root  4096 Oct 17 16:19 sbin
drwxr-xr-x   2 root root  4096 Jun 10  2012 selinux
drwxr-xr-x   2 root root  4096 Oct 17 15:46 srv
drwxr-xr-x  13 root root     0 Jan  9 17:59 sys
drwxrwxrwt   9 root root  4096 Jan  9 19:17 tmp
drwxr-xr-x  10 root root  4096 Oct 17 15:46 usr
drwxr-xr-x  12 root root  4096 Oct 17 16:14 var
lrwxrwxrwx   1 root root    26 Oct 17 15:47 vmlinuz -> boot/vmlinuz-3.2.0-4-amd64
anne@alfa:/$

Let’s make a direcoty “TEST” into / directory.
Be aware you’re logged in as default user $.
Type mkdir TEST + enter.
Your prompt will display “mkdir: cannot create directory `TEST’: Permission denied”.
As you already know the user root has ownership of the directory root.
At default the user root is the only one that can change every file and directory into our system.
User anne has no write permission, only read and execute.

We’ll create a second user Eddy and his /home/Eddy directory.
We’ve two commando’s available, useradd and adduser.
Adduser will create the new user at a interactive manner instead useradd.
We’ve chosen the low level utility useradd using the arguments -m and -U.
Short explanation of our arguments we’ll using to create new user Eddy.
-m:
Create the user’s home directory if it does not exist.
The files and directories contained in the skeleton directory (which can be defined with the
-k option) will be copied to the home directory.

-U:
Create a group with the same name as the user, and add the user to this group.
The default behavior (if the -g, -N, and -U options are not specified)
is defined by the USERGROUPS_ENAB variable in /etc/login.defs.

-p:
–password PASSWORD
The encrypted password, as returned by crypt (3).
The default is to disable the password.
Note: This option is not recommended because the password (or encrypted password) will be visible by users
listing the processes.
You should make sure the password respects the system’s password policy.

-p:
This argument will be not used because this will be visible in our terminal history.
The password will be provided using passwd commando instead useradd -p.

Let’s create user Eddy.
First login as root by typing su + enter.
You’ll be asked to fill in your “root” password + enter.
Your prompt shows # sign being root.

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

Type useradd -m -U Eddy + enter.
The new user Eddy and his home directory is added into our system.

root@alfa:/home/anne# useradd -m -U Eddy
root@alfa:/home/anne#

Check Eddy’s /home directoy by using ls command.
Our new user’s home directory has been made successfully.
Type ls -l /home + enter.

root@alfa:/home/anne# ls /home
anne  Eddy
root@alfa:/home/anne#

Restart your computer to take affect modifications.
Our user Eddy has no login password set and would be unable to login the system.
We’ll provide one at Eddy but he must change it at first login.
We’re still logged as user root so we can carry on.
Type passwd Eddy + enter.
You’ll be asked to enter Eddy’s password + enter.
Retype the same password as your first attempt +enter.
At most companies it’s a mandatory task for new user to change their login passwords.
In most cases it’s forbidden to share login passwords even by system administrators.
Users can change their own password using the same command without being root.
If users can’t remember their passwords only sysadmins are able to provide new ones.
Our user Eddy has received his password provided by our system administrator and would be able to use his freshly created account.

root@alfa:~# passwd Eddy
Enter new UNIX password: (sdf123456)
Retype new UNIX password: (sdf123456)
passwd: password updated successfully
root@alfa:~#

Now we’ve two users Eddy and anne installed into our system.
We’ll face a security breach and privacy issues which will affect both users.
Let’s take a look which permissions our users have in their home directories.
Type cd /home + enter.
Check the permissions available on both directories anne and Eddy.
Type sl -l + enter.
We discover that everyone who’s logged into the system can access both user’s home directories and read contents of it.
At company employees it isn’t  a good practice and insecure.

anne@alfa:/$ cd /home
anne@alfa:/home$ ls -l
total 8
drwxr-xr-x 25 anne anne 4096 Jan 10 14:38 anne
drwxr-xr-x 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
anne@alfa:/home$

Let’s take a closer look in /home/anne direcoty.
Type ls -Rl anne + enter.
Her folders, subfolders and files are readable by Eddy and everyone.

anne@alfa:/home$ ls -Rl anne
anne:
total 32
drwxr-xr-x 3 anne anne 4096 Nov  4 16:09 Desktop
drwxr-xr-x 3 anne anne 4096 Dec  1 14:51 Documents
drwxr-xr-x 2 anne anne 4096 Nov 16 20:18 Downloads
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Music
drwxr-xr-x 2 anne anne 4096 Dec  7 13:05 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/Desktop:
total 4
drwxr-xr-x 3 anne anne 4096 Nov  5 18:43 Gnubizz

anne/Desktop/Gnubizz:
total 8
-rw-r–r– 1 anne anne  450 Nov  5 18:43 GnubizzSite
drwxr-xr-x 4 anne anne 4096 Nov  4 16:09 OpenSourceComputing

anne/Desktop/Gnubizz/OpenSourceComputing:
total 8
drwxr-xr-x 2 anne anne 4096 Nov  5 20:54 Gnubizz1
drwxr-xr-x 2 anne anne 4096 Nov  5 20:55 Gnubizz2

anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1:
total 4
-rw-r–r– 1 anne anne 1423 Nov  5 22:25 GnubizzSite

anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2:
total 4
-rw-r–r– 1 anne anne 450 Nov  5 20:55 GnubizzSite

anne/Documents:
total 4
drwxr-xr-x 3 anne anne 4096 Jan  9 22:49 GnuBizz

anne/Documents/GnuBizz:
total 68
-rw-r–r– 1 anne anne 16999 Jan  9 22:21 INFO_USERADD
-rw-r–r– 1 anne anne 16999 Jan  9 20:37 INFO_USERADD~
-rw-r–r– 1 anne anne  9460 Jan  9 22:49 Permissions
-rw-r–r– 1 anne anne  9317 Jan  9 22:21 Permissions~
drwxr-xr-x 2 anne anne  4096 Jan  9 18:09 Published

anne/Documents/GnuBizz/Published:
total 188
-rw-r–r– 1 anne anne 31853 Nov  5 23:55 A.odt
-rw-r–r– 1 anne anne 30402 Nov 17 20:29 Application_Locations.odt
-rw-r–r– 1 anne anne 29148 Nov 12 23:55 GbuBizz
-rw-r–r– 1 anne anne 24809 Oct 29 19:22 Gnubizz
-rw-r–r– 1 anne anne 12728 Dec  7 13:38 OpenApplicationInGUIandTerminal.odt
-rw-r–r– 1 anne anne 31003 Nov 16 22:45 Programma_Locaties.odt
-rw-r–r– 1 anne anne 13496 Oct 25 12:40 TerminalExplorationInHomeDirectoryDebianWheezy7.odt

anne/Downloads:
total 0

anne/Music:
total 0

anne/Pictures:
total 0

anne/Public:
total 0

anne/Templates:
total 0

anne/Videos:
total 0
anne@alfa:/home$

Take in account that each user owns his/her home directory.
The user is able to change his/her permission on their own files and directories without being root.
We can grant three permissions available: read, write and execute.
While using chmod commando we’ll use numbers instead using read, write and execute.
The number shown below correspond each permission.
4 = read
2 = write
1 = execute

Let’s say we’ve a folder named Drive which has full permission set for all users.
It’ll look like: drwxrwxrwx 1 anna anne 4096 jan 10 15:56 Drive
We’ll avoid that everyone can access this Drive by changing some permissions.
The followed command would be: chmod 750 Drive + enter.
Now the permissions on Drive would look like: drwxr-x— 1 anna anne 4096 jan 10 15:56 Drive
Thus we’ve to count this numbers to get our permission set like shown below.
read, write and execute = 7
read and execute = 5
read and write = 6
The effective permissions on Drive would be:
750
7 = read, write and execute permission for the owner (user)
5 = read, execute permission for the group which the user belongs to.
0 = No permission set for everyone.

Ok let’s change both user’s permissions as user root.
Loggin as root by typing su + enter.
You’ll be asked to fill in your password + enter.
Your prompt will display # sign.

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

Check existing permissions at both users /home directories.
Type ls -l /home + enter.

root@alfa:/home/anne# ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Jan 10 15:56 anne
drwxr-xr-x 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
root@alfa:/home/anne#

As you already know both users are able to access each others files and directories.
We’ll change those permissions that will affect everyone users except root.
They’re no longer allowed anymore to read contents of other users.
Type chmod -R 750 /home/Eddy + enter.
The argument -R will force the permission on the sub-folders as well.

root@alfa:/home/anne# ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Jan 10 15:56 anne
drwxr-xr-x 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
root@alfa:/home/anne# chmod 750 /home/Eddy
root@alfa:/home/anne#

Check if the change has took place.
We notice the permission by everyone has changed.
Type ls -l /home + enter.

root@alfa:/home/anne# ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Jan 10 15:56 anne
drwxr-xr-x 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
root@alfa:/home/anne# chmod 750 /home/Eddy
root@alfa:/home/anne# ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Jan 10 15:56 anne
drwxr-x— 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
root@alfa:/home/anne#

Logout as user root by typing exit + enter.
Your prompt displays $ again.
Now we’re ready to test if our permissions works.
We’re logged in as anne.
Navigate to /home by typing cd /home + enter.
Our working directory is /home that contains the sub-folders anne and Eddy.
Type ls + enter.

anne@alfa:~$ cd /home
anne@alfa:/home$ ls
anne  Eddy
anne@alfa:/home$

Ok we would like to see anne’s subdirectories.
You’ll see all the folders owned by anne.
Type ls anne + enter.

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

We’ll redo this command to see Eddy’s sub-directories.
Hm, We’ll encounter a issue displayed below.
Our output give us the reason why this task can’t be performed.
ls: cannot open directory Eddy: Permission denied
We’ve no read permission anymore because we belongs to the users “everyone”.
Type ls Eddy + enter.

anne@alfa:~$ cd /home
anne@alfa:/home$ ls
anne  Eddy
anne@alfa:/home$ ls anne
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne@alfa:/home$ ls Eddy
ls: cannot open directory Eddy: Permission denied
anne@alfa:/home$

Can we access his home directoy? I don’t think so.
Let’s test it and type cd Eddy + enter.
No success  to access it which protects Eddy’s privacy.
Our output displays the reason why: cd: Eddy: Permission denied

anne@alfa:~$ cd /home
anne@alfa:/home$ ls
anne  Eddy
anne@alfa:/home$ ls anne
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne@alfa:/home$ ls Eddy
ls: cannot open directory Eddy: Permission denied
anne@alfa:/home$ cd Eddy
bash: cd: Eddy: Permission denied
anne@alfa:/home$

We’ve shown how to set permissions at user level but this can become complicated when having much users.
In our example we’ve only two users which are easy manageable.
Our users are divided into two different primary groups anne and Eddy.
Type ls -l + enter.

root@alfa:/home# ls -l
total 8
drwxr-x— 25 anne anne 4096 Jan 11 12:03 anne
drwxr-x— 19 Eddy Eddy 4096 Jan  9 22:39 Eddy
root@alfa:/home#

The best practice is to set permissions at group level instead of users.
We’ll create two users Bert and Vivianne by executing useradd.
We will create a new supplementary group _gnubizzers using groupadd.
A directory GNUBIZZ-DRIVE will be created in our / home directory.
Create both users Bert, Vivianne and their /home directories.
Type useradd -m -U Bert + enter.

anne@alfa:~$ su
Password:
root@alfa:/home/anne# useradd -m -U Bert
root@alfa:/home/anne#

Repeat this command creating user Vivianne.
Type useradd -m -U Vivianne + enter.

anne@alfa:~$ su
Password:
root@alfa:/home/anne# useradd -m -U Bert
root@alfa:/home/anne# useradd -m -U Vivianne
root@alfa:/home/anne#

Restart your computer so the system can write down the modifications you’ve just made.
Check if both users exist by ls commando.
Now we see four users anne, Bert, Eddy and Vivianne.
Type ls /home + enter.

root@alfa:/home/anne# ls /home
anne  Bert  Eddy  Vivianne
root@alfa:/home/anne#

Asign users Bert and Vivianne a login password.
Type passwd Bert + enter.
You’ll be asked to fill in Bert’s new password + enter.
Retype this password + enter.
Do the same task by the user Vivianne.

root@alfa:/home/anne# passwd Bert
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@alfa:/home/anne# passwd Vivianne
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
root@alfa:/home/anne#

Check the newly user’s permissions by typing ls -l + enter.
Other users are able to read contents of both users Bert and Vivianne.
When you don’t like it to happen you’ve to change it.
Type chmod 750 Bert Vivianne + enter.

root@alfa:/home# ls -l
total 16
drwxr-x— 25 anne     anne     4096 Jan 11 21:48 anne
drwxr-xr-x 19 Bert     Bert     4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy     4096 Jan 11 21:30 Eddy
drwxr-xr-x 19 Vivianne Vivianne 4096 Jan 11 21:47 Vivianne
root@alfa:/home# chmod 750 Bert Vivianne
root@alfa:/home# ls -l
total 16
drwxr-x— 25 anne     anne     4096 Jan 11 21:48 anne
drwxr-x— 19 Bert     Bert     4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy     4096 Jan 11 21:30 Eddy
drwxr-x— 19 Vivianne Vivianne 4096 Jan 11 21:47 Vivianne
root@alfa:/home#

Our next task is creating our directory GNUBIZZ-DRIVE using mkdir commando in the /home directory.
Navigate to /home using cd.
Type mkdir GNUBIZZ-DRIVE + enter.
We’ll face a permission issue by “Permission denied” because we were executing our command as default user.
The directory /home is owned by root.
Login as root by typing su + enter.
Typ your password + enter and retype it again + enter.
Now we’ll be able to perform this task.
Type mkdir GNUBIZZ-DRIVE + enter.
Check by ls -l and you’ll see our newly directoy GNUBIZZ-DRIVE and it’s permissions.
As you can see everyone has read and execute permissions at GNUBIZZ-DRIVE owned by root.

anne@alfa:/home$ mkdir GNUBIZZ-DRIVE
mkdir: cannot create directory `GNUBIZZ-DRIVE’: Permission denied
anne@alfa:/home$ su
Password:
root@alfa:/home# mkdir GNUBIZZ-DRIVE
root@alfa:/home# ls -l
total 20
drwxr-x— 26 anne     anne     4096 Jan 11 22:19 anne
drwxr-x— 19 Bert     Bert     4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy     4096 Jan 11 21:30 Eddy
drwxr-xr-x  2 root     root     4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne 4096 Jan 11 21:47 Vivianne
root@alfa:/home#

Change permission at GNUBIZZ-DRIVE so others aren’t able to gain access to it.
Type chmod 750 GNUBIZZ-DRIVE + enter.
At this stage user root and group root has still permissions set.
Check this by ls -l + enter.

root@alfa:/home# chmod 750 GNUBIZZ-DRIVE
root@alfa:/home# ls -l
total 20
drwxr-x— 26 anne     anne     4096 Jan 11 22:19 anne
drwxr-x— 19 Bert     Bert     4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy     4096 Jan 11 21:30 Eddy
drwxr-x—  2 root     root     4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne 4096 Jan 11 21:47 Vivianne
root@alfa:/home#

Now we’re ready to go further using groups instead of users.
Our purpose is to make users members of specific groups.
Our system handles two kinds of groups, primary and supplementary.
Each user becomes a member of a primary group when we created them.
Let’s look which group our users belongs to using id commando.
Type id username + enter.
Here we can see our primary groups of our users:
anne’s primary group is “anne”
Eddy’s primary group is “Eddy”
Bert’s primary group is “Bert”
Viviannes’s primary group is “Vivianne”

anne@alfa:~$ id anne
uid=1000(anne) gid=1000(anne) groups=1000(anne),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),106(scanner),111(bluetooth),113(netdev)
anne@alfa:~$ id Eddy
uid=1001(Eddy) gid=1001(Eddy) groups=1001(Eddy)
anne@alfa:~$ id Bert
uid=1002(Bert) gid=1002(Bert) groups=1002(Bert)
anne@alfa:~$ id Vivianne
uid=1003(Vivianne) gid=1003(Vivianne) groups=1003(Vivianne)
anne@alfa:~$

First we’ll create a new group named _gnubizzers.
To perform this you’ll need high privileges being root.
Login as user root by typing su + enter.
Fill in password of root user + enter.
Retype password + enter.
Your prompt will displays # again.
Create the group _gnubizzers using groupadd commando.
Type groupadd _gnubizzers + enter.

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

Our group _gnubizzers is abandon containing no members yet.
We’ll add users Eddy, Bert and Vivianne to _gnubizzers using usermod commando.
Take in account that our users and group already exist so we’ll use some arguments.
A short arguments -a and -G  explanation:
-a = Append existing user to the group
-G = Specify supplementary group which the user will join.
Be aware and use your root user.
We’re still logged in as root so we’ll continue to make our users members of _gnubizzers.
Type usermod -a -G _gnubizzers Eddy + enter.
Check Eddy’s groups membership using id commando.
Type id Eddy + enter.
Eddy’s primary group is “Eddy” and his supplementary group is “_gnubizzers”

root@alfa:/home# usermod -a -G _gnubizzers Eddy
root@alfa:/home# id Eddy
uid=1001(Eddy) gid=1001(Eddy) groups=1001(Eddy),1004(_gnubizzers)
root@alfa:/home#

Repeat this task by the users Bert and Vivianne.
Type usermod -a -G _gnubizzers Bert + enter.
Than type usermod -a -G _gnubizzers Vivianne + enter.
The group _gnubizzers contains three members Eddy, Bert and Vivanne.
Check their membership using id command followed by their username.
Type id Bert + enter.
Redo this command at the user Vivianne.
You we’ll see  _gnubizzers is added as a supplementary group.

root@alfa:/home# usermod -a -G _gnubizzers Bert
root@alfa:/home# usermod -a -G _gnubizzers Vivianne
root@alfa:/home# id Bert
uid=1002(Bert) gid=1002(Bert) groups=1002(Bert),1004(_gnubizzers)
root@alfa:/home# id Vivianne
uid=1003(Vivianne) gid=1003(Vivianne) groups=1003(Vivianne),1004(_gnubizzers)
root@alfa:/home#

At this moment our members of the group _gnubizzers has no permissions on GNUBIZZ-DRIVE.
Let’s check this using ls -l /home + enter.
We see GNUBIZZ-DRIVE is owned by root and group root.
Our purpose is to change the group ownership from root to _gnubizzers.
At this stage displayed below our user root has full permission and the group root has read and execute permissions.

anne@alfa:~$ ls -l /home
total 20
drwxr-x— 25 anne     anne     4096 Jan 14 11:23 anne
drwxr-x— 19 Bert     Bert     4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy     4096 Jan 11 21:30 Eddy
drwxr-x—  2 root     root     4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne 4096 Jan 11 21:47 Vivianne
anne@alfa:~$

Let’s change the group ownership by using chgrp commando.
We’ll insert some arguments like -v and -R.
-v Is used to see the diagnostics what happened .
-R Is used to operate on files and directories recursively.
Type chgrp -v -R _gnubizzers /home/GNUBIZZ-DRIVE + enter.
Our output displays that the group has changed from root to _gnubizzers.

anne@alfa:~$ su
Password:
root@alfa:/home/anne# chgrp -v -R _gnubizzers /home/GNUBIZZ-DRIVE
changed group of `/home/GNUBIZZ-DRIVE’ from root to _gnubizzers
root@alfa:/home/anne#

Check using ls -l verifying the changes.
The directory GNUBIZZ-DRIVE is still owned by user root but the group ownership has changed to _gnubizzers.
The group _gnubizzers are able to read and execute in the directory GNUBIZZ-DRIVE.

root@alfa:/home/anne# ls -l /home
total 20
drwxr-x— 25 anne     anne        4096 Jan 14 11:23 anne
drwxr-x— 19 Bert     Bert        4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy        4096 Jan 11 21:30 Eddy
drwxr-x—  2 root     _gnubizzers 4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne    4096 Jan 11 21:47 Vivianne
root@alfa:/home/anne#

We’ll change the permissions on GNUBIZZ-DRIVE so our members of the  group _gnubizzers will be able to read, write and execute.
Login as root using su.
Type chmod 770 /home/GNUBIZZ-DRIVE + enter.
Verify your changes using ls -l /home + enter.
The user root (owner) and the group _gnubizzers (group owner) has the same permissions on GNUBIZZ-DRIVE.
Be aware that this situation is far from ideal and insecure using such configurations at companies.
Each member is able to write, change, move, store and even delete other member’s directories and files by accident.
How to avoid this will be discussed later on.

root@alfa:/home/anne# ls -l /home
total 20
drwxr-x— 25 anne     anne        4096 Jan 14 11:23 anne
drwxr-x— 19 Bert     Bert        4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy        4096 Jan 11 21:30 Eddy
drwxr-x—  2 root     _gnubizzers 4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne    4096 Jan 11 21:47 Vivianne
root@alfa:/home/anne# chmod 770 /home/GNUBIZZ-DRIVE
root@alfa:/home/anne# ls -l /home
total 20
drwxr-x— 25 anne     anne        4096 Jan 14 11:23 anne
drwxr-x— 19 Bert     Bert        4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy        4096 Jan 11 21:30 Eddy
drwxrwx—  2 root     _gnubizzers 4096 Jan 11 22:28 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne    4096 Jan 11 21:47 Vivianne
root@alfa:/home/anne#

We’ll show you a security breach on GNUBIZZ-DRIVE.
Login as user Eddy in the same terminal you working on.
First become user root before using login commando.
Type login Eddy + enter.
You’ll be asked to fill in Eddy’s password + enter.
You’re now logged in as “Eddy”.
Verify who is logged by using whoami command.
Type whoami + enter.
Eddy will be displayed.
Check Eddy’s working directory by pwd commando.
Type pwd + enter.
Eddy’s working directory would be /home/Eddy.
Navigate to GNUBIZZ-DRIVE by typing cd /home/GNUBIZZ-DRIVE + enter.
Eddy will create a sub-directory “Eddy-gnu”.
Type mkdir Eddy-gnu + enter.
Verify with ls and Eddy will see his new directory Eddy-gnu stored at GNUBIZZ-DRIVE.
Logout by typing exit + enter and you’ll become root user.
Your prompt shows # sign again being root user.

root@alfa:/home/anne# login Eddy
Password:
Last login: Tue Jan 14 12:43:58 CET 2014 on pts/0
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ whoami
Eddy
$ pwd
/home/Eddy
$ cd /home/GNUBIZZ-DRIVE
$ pwd
/home/GNUBIZZ-DRIVE
$ mkdir Eddy-gnu
$ ls
Eddy-gnu
$ exit
root@alfa:/home/anne#

So far nothing happened yet to proof our configuration issue.
Login as user Vivianne.
Verify Vivianne’s working directory by pwd.
Navigate to GNUBIZZ-DRIVE.
Check which directories are stored at GNUBIZZ-DRIVE by ls -l.
Vivianne will see Eddy’s directory Eddy-gnu.
Take in account the whole group _gnubizzers has full rights on GNUBIZZ-DRIVE.
Let’s test our security risk by removing Eddy’s folder.
Type rmdir Eddy-gnu + enter.
Use ls and you’ll see Eddy’s directory Eddy-gnu is gone.
This is not a good practice being able to delete each others folders and files.
Logout by typing exit + enter.
We’re root again and ready to modify it at a better way.

root@alfa:/home/anne# login Vivianne
Password:
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ pwd
/home/Vivianne
$ cd /home/GNUBIZZ-DRIVE
$ ls -l
total 4
drwxr-xr-x 2 Eddy Eddy 4096 Jan 14 12:52 Eddy-gnu
$ rmdir Eddy-gnu
$ ls
$ exit
root@alfa:/home/anne#

Our goal is working more secure for everyone who’s member of the group _gnubizzers.
Let’s change our permission using a sticky bit.
The user root will not be affected by sticky bit and the permission will remain unchanged.
This will prevent the user being able by deleting files and directories accidently by other users which belongs to the same group _gnubizzers.
Set your permission on GNUBIZZ-DRIVE using chmod commando.
Type chmod -v 1770 /home/GNUBIZZ-DRIVE + enter.
Check this by ls -l /home + enter.

root@alfa:/home/anne# chmod -v 1770 /home/GNUBIZZ-DRIVE
mode of `/home/GNUBIZZ-DRIVE’ changed from 0770 (rwxrwx—) to 1770 (rwxrwx–T)
root@alfa:/home/anne# ls -l /home
total 20
drwxr-x— 25 anne     anne        4096 Jan 14 11:23 anne
drwxr-x— 19 Bert     Bert        4096 Jan 11 21:45 Bert
drwxr-x— 19 Eddy     Eddy        4096 Jan 11 21:30 Eddy
drwxrwx–T  2 root     _gnubizzers 4096 Jan 14 12:59 GNUBIZZ-DRIVE
drwxr-x— 19 Vivianne Vivianne    4096 Jan 11 21:47 Vivianne
root@alfa:/home/anne#

Our security breach must be solved so we’ll test it again.
Type the bold text displayed in our example below.
The red text represents our terminal output.
Just follow this small content and explore and discuss your thoughts.
Don’t forget to be root when logging as another user in the same terminal.
Login as user Eddy and create a directory Eddy-gnu at GNUBIZZ-DRIVE.

root@alfa:/home/anne# login Eddy
Password:
Last login: Tue Jan 14 12:44:45 CET 2014 on pts/0
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ pwd
/home/Eddy
$ cd /home/GNUBIZZ-DRIVE
$ pwd
/home/GNUBIZZ-DRIVE
$ mkdir Eddy-gnu
$ ls -l
total 4
drwxr-xr-x 2 Eddy Eddy 4096 Jan 14 13:27 Eddy-gnu
$ exit
root@alfa:/home/anne#

Login as user Bert and Vivianne and create sub-directory correspond by username:
Vivianne will create directory Vivianne-gnu.
Bert will create directory Bert-gnu.
Type the bold text displayed below.
Login as user Bert and perform the task described above.

root@alfa:/home/anne# login Bert
Password:
Last login: Tue Jan 14 13:30:39 CET 2014 on pts/0
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ pwd
/home/Bert
$ cd /home/GNUBIZZ-DRIVE
$ ls
Eddy-gnu
$ mkdir Bert-gnu
$ ls -l
total 8
drwxr-xr-x 2 Bert Bert 4096 Jan 14 13:31 Bert-gnu
drwxr-xr-x 2 Eddy Eddy 4096 Jan 14 13:27 Eddy-gnu
$$ exit
root@alfa:/home/anne#

Login as user Vivianne and create a sub-directory Vivianne-gnu at GNUBIZZ-DRIVE.
Type the bold text and follow our example below.

root@alfa:/home/anne# login Vivianne
Password:
Last login: Tue Jan 14 12:58:36 CET 2014 on pts/0
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ pwd
/home/Vivianne
$ cd /home/GNUBIZZ-DRIVE
$ mkdir Vivianne-gnu
$ ls -l
total 12
drwxr-xr-x 2 Bert     Bert     4096 Jan 14 13:31 Bert-gnu
drwxr-xr-x 2 Eddy     Eddy     4096 Jan 14 13:27 Eddy-gnu
drwxr-xr-x 2 Vivianne Vivianne 4096 Jan 14 13:42 Vivianne-gnu
$ exit
root@alfa:/home/anne#

Let’s see if users can delete files and directories by accident of othter members.
Login as user Eddy again.
Eddy will remove other members their directories stored at GNUBIZZ-DRIVE.
The bold text must be typed. Explore what will happen and enjoy it.
Nobody of the group _gnubizzers will be able to delete each others files and direcoties.
Notice they’re still be able to read each others contents but they can’t create or remove contents at other members.

If you don’t like that group members are able to read your contents you can change it at your own folders and files stored at GNUBIZZ_DRIVE.
A example what a group member can do.
Supposing Eddy don’t like that others are able to read his contents.
At this stage permissions read and execute rights on Eddy’s-gnu owned by Eddy are granted  for everyone.
drwxr-xr-x 2 Eddy     Eddy     4096 Jan 14 13:27 Eddy-gnu
Eddy can change this by executing chmod 750 Eddy-gnu to avoid reading permissions by others.
Now his folder permission would like this:
drwxr-x— Eddy     Eddy     4096 Jan 14 13:27 Eddy-gnu
The members of the group _gnubizzers aren’t able anymore to read Eddy’s folders and files contents.
Setting permissions can become very complicated and must be well documented by system administrators.

root@alfa:/home/anne# login Eddy
Password:
Last login: Tue Jan 14 13:27:13 CET 2014 on pts/0
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
$ pwd
/home/Eddy
$ cd /home/GNUBIZZ-DRIVE
$ ls -l
total 12
drwxr-xr-x 2 Bert     Bert     4096 Jan 14 13:31 Bert-gnu
drwxr-xr-x 2 Eddy     Eddy     4096 Jan 14 13:27 Eddy-gnu
drwxr-xr-x 2 Vivianne Vivianne 4096 Jan 14 13:42 Vivianne-gnu
$ rmdir Bert-gnu
rmdir: failed to remove `Bert-gnu’: Operation not permitted
$ rmdir Vivianne-gnu
rmdir: failed to remove `Vivianne-gnu’: Operation not permitted
$ exit
root@alfa:/home/anne# 

A permission overview configured in our example.
Our system has four users anne, Eddy, Bert and Vivianne.
Membership _gnubizzers:
Eddy, Bert and Vivianne
Non membership of _gnubizzers:
anne and root
The permissions set at users home direcories:
Read, write and execute by the owner (user itself).
Read and execute permission granted at primary group which user belongs to.
No rights granted for everyone.
Permission set at GNUBIZZ-DRIVE shared by the group _gnubizzers:
Read, write and execute rights granted user root.
Read, write and execute rights granted to _gnubizzers members.
Sticky bit set preventing by removing contents of other members.
No rights granted for everyone

So that’s it and we hope you’ve enjoyed it.
Feel free to share your thoughts so we can get things going better.
Don’t hesitate to leave a comment.
We’ll back soon to giude you through this nice system Debian Wheezy 7.2. ;-)

Written by Anne-Marie.

Turn your Debian Wheezy 7.2 system into a Samba Server.

Turn your Debian Wheezy 7.2 system into a Samba Server.

We’ve already installed our Debian Wheezy 7.2 system and now it runs a desktop environment. Our purpose is to run it as a Samba server.
We’ll deploy shared drives and print services to our Windows clients.
The most companies runs DFS ( Distributed File Services ) and Print Services deployed by their servers.
Samba server communicates using SMB ( Simple Message Block ) protocol which are supported in most systems.

In this tutorial we’ll install and test our Samba Server.
Each pc that connects to a network receives their ip addresses automatically assigned by DHCP ( Dynamic Host Configuration Protocol ).
A ip address assigned by dhcp is not optimal for servers so we’ll assign our machine a static one.
We can check our ip settings of our machine by executing ifconfig.
Type ifconfig + enter.

anne@Samba:~$ ifconfig
bash: ifconfig: command not found
anne@Samba:~$


Oops what’s went wrong inhere?

In the most Linux machines you’ll get your ip settings displayed but in Debian Wheezy you’ll see bash: ifconfig: command not found.
We’ve discussed in previous tutorials how to find locations of commando’s.
If you like you can review “Applications and commando’s locations Debian Wheezy 7″ article.
The location of ifconfig is /sbin directory.
Let’s continue revealing our machine’s ip settings.
Type /sbin/ifconfig + enter.
We have two interfaces displayed in our output, etho and a loopback 0 interface.

anne@Samba:~$ ifconfig
bash: ifconfig: command not found
anne@Samba:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:a8:9a:9a 
          inet addr:192.168.0.233  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea8:9a9a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5641 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3726 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:5746232 (5.4 MiB)  TX bytes:635055 (620.1 KiB)

 lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

anne@Samba:~$


Our machine ip settings assigned by dhcp are:

ip: 192.168.0.233/24
subnetmask: 255.255.255.0
Our default gateway is missing at this moment but we’ll execute netstat command to reveal this.
Type netstat -r + enter.

anne@Samba:~$ netstat -r
Kernel IP routing table
Destination        Gateway           Genmask              Flags    MSS Window  irtt Iface
default                 192.168.0.1      0.0.0.0                 UG              0 0                  0 eth0
link-local             *                        255.255.0.0         U                 0 0                  0 eth0
192.168.0.0        *                         255.255.255.0     U                 0 0                  0 eth0
anne@Samba:~$


Now we know our important ip settings assigned by dhcp.

Complete machine ip settings are:
ip: 192.168.0.233/24
subnetmask: 255.255.255.0
default gateway: 192.168.0.1

The best practice is to write down your ip settings on a piece of paper because you’ll need it later on.
Our next task is important before proceeding by installing our samba server.
We need a static ip address instead a assigned one by dhcp.
First off all we’ve to shutdown some services like avahi-daemon and network-manager.
On a server they’re annoying because they startup by system boot with the purpose to give a ip address assigned by dhcp.
Don’t do this at desktops, laptops and other devices, they need this services to work properly while connecting to a network.
The services network-manager and avahi-daemon are located in the directory /etc/rc2.d.
Let’s take a look and type cd /etc/rc2.d + enter and than type ls -l + enter.
Now we’ll see all our services here including avahi-daemon and network-manager displayed below.
The links of our services are bold and underlined tekst displayed below.

anne@Samba:~$ cd /etc/rc2.d
anne@Samba:/etc/rc2.d$ ls -l
total 4
-rw-r–r– 1 root root 677 Jul 14 19:24 README
lrwxrwxrwx 1 root root  14 Oct 17 15:46 S01motd -> ../init.d/motd
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S13rpcbind -> ../init.d/rpcbind
lrwxrwxrwx 1 root root  20 Oct 17 16:14 S14nfs-common -> ../init.d/nfs-common
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S16acpi-fakekey -> ../init.d/acpi-fakekey
lrwxrwxrwx 1 root root  24 Oct 17 16:14 S16binfmt-support -> ../init.d/binfmt-support
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S16rsyslog -> ../init.d/rsyslog
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S16sudo -> ../init.d/sudo
lrwxrwxrwx 1 root root  32 Oct 17 16:14 S16virtualbox-guest-utils -> ../init.d/virtualbox-guest-utils
lrwxrwxrwx 1 root root  15 Oct 17 16:14 S17acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S17acpi-support -> ../init.d/acpi-support
lrwxrwxrwx 1 root root  17 Oct 17 16:14 S17anacron -> ../init.d/anacron
lrwxrwxrwx 1 root root  13 Oct 17 16:14 S17atd -> ../init.d/atd
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S17cron -> ../init.d/cron
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S17dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root  15 Oct 17 16:14 S17exim4 -> ../init.d/exim4
lrwxrwxrwx 1 root root  27 Oct 17 16:14 S17speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root  22 Oct 17 16:14 S18avahi-daemon -> ../init.d/avahi-daemon
lrwxrwxrwx 1 root root  19 Oct 17 16:14 S18bluetooth -> ../init.d/bluetooth
lrwxrwxrwx 1 root root  25 Oct 17 16:14 S18network-manager -> ../init.d/network-manager
lrwxrwxrwx 1 root root  14 Oct 17 16:14 S19cups -> ../init.d/cups
lrwxrwxrwx 1 root root  14 Oct 17 16:15 S19gdm3 -> ../init.d/gdm3
lrwxrwxrwx 1 root root  20 Oct 17 16:14 S19pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx 1 root root  15 Oct 17 16:15 S19saned -> ../init.d/saned
lrwxrwxrwx 1 root root  18 Oct 17 16:15 S20bootlogs -> ../init.d/bootlogs
lrwxrwxrwx 1 root root  19 Oct 17 16:15 S21minissdpd -> ../init.d/minissdpd
lrwxrwxrwx 1 root root  18 Oct 17 16:15 S21rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root  19 Oct 17 16:15 S21rmnologin -> ../init.d/rmnologin
anne@Samba:/etc/rc2.d$


Ok we’ll remove the links of both services using the command rm. You must have high privileges on your system so you’ve to use your root user.

Type su + enter.
You’ll be asked to fill in your root password followed by enter.
The sign # represents that you’re logged in as user root.
Be aware when you’re changing things in here because you’ve full privileges on your system. This actions will affect your system’s behavior.
Let’s remove the links of our services by using mv command.

Type rm -v /etc/rc2.d/S18avahi-daemon + enter.
than,
Type rm -v /etc/rc2.d/S18network-manager + enter.
We’ve used the -v option to see what happens after our execution.

As you can see they’re successfully removed.

anne@Samba:/etc/rc2.d$ su
Password:
root@Samba:/etc/rc2.d#rm -v /etc/rc2.d/S18avahi-daemon
removed `/etc/rc2.d/S18avahi-daemon’
root@Samba:/etc/rc2.d# rm -v /etc/rc2.d/S18network-manager
removed `/etc/rc2.d/S18network-manager’
root@Samba:/etc/rc2.d#


We’ve no links to our services anymore so we’ll create a new one as followed.

Type ln -s /etc/init.d/networking /etc/rc2.d/S15networking + enter.
Now we’ve a new link that leads to our directory /etc/init.d/networking.

anne@Samba:/etc/rc2.d$ su
Password:
root@Samba:/etc/rc2.d#rm -v /etc/rc2.d/S18avahi-daemon
removed `/etc/rc2.d/S18avahi-daemon’
root@Samba:/etc/rc2.d# rm -v /etc/rc2.d/S18network-manager
removed `/etc/rc2.d/S18network-manager’
root@Samba:/etc/rc2.d# ln -s /etc/init.d/networking /etc/rc2.d/S15networking


Ok, we’re ready to stop our services avahi-deamon and network-manager as followed.

Type /etc/init.d/avahi-daemon stop + enter.
than,
Type /etc/init.d/network-manager stop + enter.
If you prefer you can just restart your machine. It’s causes the same results.

We can see in our output that our services are stopped successfully.

root@Samba:/etc/rc2.d# /etc/init.d/avahi-daemon stop
[ ok ] Stopping Avahi mDNS/DNS-SD Daemon: avahi-daemon.
root@Samba:/etc/rc2.d# /etc/init.d/network-manager stop
[ ok ] Stopping network connection manager: NetworkManager.
root@Samba:/etc/rc2.d#


Hmm, alright, let’s continue by taking care of our ip settings.

We’ll give our machine a static ip address before being able to install our samba.
As you already know our system is built up of directories and files.
The configuration files we need are located at the directory /etc.
Type cd /etc + enter.
Our working directory /etc so we’re interested in the network files. Let’s take a look.
Type ls net* + enter.

anne@Samba:~$ cd /etc
anne@Samba:/etc$
ls net*
netconfig  networks

network:
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  run
anne@Samba:/etc$


We see the file interfaces located in our  sub directory network.

Go to that directory and type cd network + enter.
Now we’re in our working directory network which contains the file interfaces.

anne@Samba:/etc$ cd network
anne@Samba:/etc/network$
ls
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  run
anne@Samba:/etc/network$


Each file can be changed that affect our system’s behavior so pay attention while you’re changing files like this one.
Let’s take a look at the contents of the file interfaces by using our cat. If you have any doubts you can check it’s properties by executing command file.

Type file interfaces + enter.
Our file interfaces is a ASCII-tekst based file so we’re able to read it’s contents by performing the cat command.
Type cat interfaces + enter.
This file contains the available interfaces on your system and can be modified if it’s necessary to do so like assigning ip addresses.

anne@Samba:/etc/network$ file interfaces
interfaces: ASCII text
anne@Samba:/etc/network$ cat interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
anne@Samba:/etc/network$


Let’s check all our interfaces available in our machine by executing ls.

Type lspci + enter.
Here you discover your Ethernet Controller shown below.
Type lspci + enter.
Here you see our Ethernet Controller displayed below.
Everything seems to be alright so far.

root@Samba:/etc/network# lspci
00:00.0 Host bridge: Intel Corporation 440FX – 82441FX PMC [Natoma] (rev 02)
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter
00:03.0 Ethernet controller: Intel Corporation 82540EM Gigabit Ethernet Controller (rev 02)
00:04.0 System peripheral: InnoTek Systemberatung GmbH VirtualBox Guest Service

00:05.0 Multimedia audio controller: Intel Corporation 82801AA AC’97 Audio Controller (rev 01)
00:06.0 USB controller: Apple Inc. KeyLargo/Intrepid USB
00:07.0 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:0d.0 SATA controller: Intel Corporation 82801HM/HEM (ICH8M/ICH8M-E) SATA Controller [AHCI mode] (rev 02)
root@Samba:/etc/network#


Let’s start our static ip configuration by opening our file interfaces using Pico.

We’re still root user with high privileges so we can carry on.
We hope you’ve written down your ip settings.
Type pico interfaces +  enter.
Your file may look like this.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback


Write your ip settings you like to use as static ip.

We’ve chosen a /24 network 192.168.0.0
Our samba server will use ip 192.168.0.254
Subnetmask 255.255.255.0
Gateway 192.168.0.1
A little explanation about the file we’re modifying:
auto eth0 stands for startup ethernet interface 0 while system boots.
Iface eth0 inet static indicates a static assigned address at ethernet interface 0
These ip addresses displayed here are just examples so you can use your own settings you prefer.
Take note you can’t use a ip address twice and you must pay attention not to use addresses served by dhcp.
Navigate your cursor below using your arrow keys.
Write in our file the followed tekst:
auto eth0
iface eth0 init static
address 192.168.0.254
netmask 255.255.255.0
gateway 192.168.0.1

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.254
netmask 255.255.255.0
gateway 192.168.0.1


If it’s correct save your file without changing the name of it.

Press ctrl + x and type y to save your file.
Don’t change anything here but just press enter.
Your file is now saved and ready to use after restarting our network services as followed.

We do this so the system can write down the changes we’ve just made.
Type /etc/init.d/networking restart + enter.
This will restart the network services.
Leave your root by typing exit.
Your prompt shown the $ again that indicates the default user.

Check your ip settings by typing /sbin/ifconfig + enter.
We can see our static ip settings listed below.
ip 192.168.0.254
subnetmask 255.255.255.0
defaul gateway 192.168.0.1

anne@Samba:~$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:a8:9a:9a 
          inet addr:192.168.0.254  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea8:9a9a/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1595 errors:0 dropped:0 overruns:0 frame:0
          TX packets:164 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:251030 (245.1 KiB)  TX bytes:19119 (18.6 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

 anne@Samba:~$


We’ll test our connectivity by executing the ping command.

Type ping www.google.com + enter.
You’ll see a output like below if you’re connected successfully.
Notice we have transmitted 4 packets and received four. None of them were lost.
Stop you ping by pressing ctrl +c.

anne@Samba:~$ ping http://www.google.com
PING http://www.google.com (74.125.136.104) 56(84) bytes of data.
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=1 ttl=46 time=23.5 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=2 ttl=46 time=25.7 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=3 ttl=46 time=23.8 ms
64 bytes from ea-in-f104.1e100.net (74.125.136.104): icmp_req=4 ttl=46 time=23.1 ms
^C
http://www.google.com ping statistics —
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 23.113/24.050/25.723/0.999 ms
anne@Samba:~$


Now we’re able to install our Samba server.

Login as user root by performing su + enter.
Type your root user password + enter.
Your prompt shows the #  sign instead the default $ sign.
Ok, let’s do it.
Typ apt-get install samba + enter.

anne@Samba:~$ su
Password:
root@Samba:/home/anne# apt-get install samba
Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following extra packages will be installed:
  libwbclient0 samba-common smbclient tdb-tools
Suggested packages:
  openbsd-inetd inet-superserver smbldap-tools ldb-tools ctdb cifs-utils
The following NEW packages will be installed:
  samba tdb-tools
The following packages will be upgraded:
  libwbclient0 samba-common smbclient
3 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 10.5 MB of archives.
After this operation, 23.8 MB of additional disk space will be used.
Do you want to continue [Y/n]?


Now you can make a decision here.

We can see what will happen during this installation and how much disk space will be used.
You can abort this by pressing n but we’ll proceed the installation by pressing y.
Type y + enter.
Our samba server will be installed and a long list will roll on our terminal.

root@Samba:/home/anne# apt-get install samba
Reading package lists… Done
Building dependency tree      
Reading state information… Done
The following extra packages will be installed:
  libwbclient0 samba-common smbclient tdb-tools
Suggested packages:
  openbsd-inetd inet-superserver smbldap-tools ldb-tools ctdb cifs-utils
The following NEW packages will be installed:
  samba tdb-tools
The following packages will be upgraded:
  libwbclient0 samba-common smbclient
3 upgraded, 2 newly installed, 0 to remove and 27 not upgraded.
Need to get 10.5 MB of archives.
After this operation, 23.8 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ftp.belnet.be/debian/ wheezy/main tdb-tools amd64 1.2.10-2 [27.0 kB]
Get:2 http://security.debian.org/ wheezy/updates/main libwbclient0 amd64 2:3.6.6-6+deb7u2 [95.7 kB]
Get:3 http://security.debian.org/ wheezy/updates/main smbclient amd64 2:3.6.6-6+deb7u2 [5,891 kB]
Get:4 http://security.debian.org/ wheezy/updates/main samba-common all 2:3.6.6-6+deb7u2 [213 kB]
Get:5 http://security.debian.org/ wheezy/updates/main samba amd64 2:3.6.6-6+deb7u2 [4,322 kB]
Fetched 10.5 MB in 5s (2,059 kB/s)
Reading changelogs… Done
Preconfiguring packages …
(Reading database … 142221 files and directories currently installed.)
Preparing to replace libwbclient0:amd64 2:3.6.6-6+deb7u1 (using …/libwbclient0_2%3a3.6.6-6+deb7u2_amd64.deb) …
Unpacking replacement libwbclient0:amd64 …
Preparing to replace smbclient 2:3.6.6-6+deb7u1 (using …/smbclient_2%3a3.6.6-6+deb7u2_amd64.deb) …
Unpacking replacement smbclient …
Preparing to replace samba-common 2:3.6.6-6+deb7u1 (using …/samba-common_2%3a3.6.6-6+deb7u2_all.deb) …
Unpacking replacement samba-common …
Selecting previously unselected package samba.
Unpacking samba (from …/samba_2%3a3.6.6-6+deb7u2_amd64.deb) …
Selecting previously unselected package tdb-tools.
Unpacking tdb-tools (from …/tdb-tools_1.2.10-2_amd64.deb) …
Processing triggers for man-db …
Setting up libwbclient0:amd64 (2:3.6.6-6+deb7u2) …
Setting up samba-common (2:3.6.6-6+deb7u2) …
Setting up smbclient (2:3.6.6-6+deb7u2) …
Setting up samba (2:3.6.6-6+deb7u2) …
Generating /etc/default/samba…
Adding group `sambashare’ (GID 123) …
Done.
update-alternatives: using /usr/bin/smbstatus.samba3 to provide /usr/bin/smbstatus (smbstatus) in auto mode
[ ok ] Starting Samba daemons: nmbd smbd.
Setting up tdb-tools (1.2.10-2) …
update-alternatives: using /usr/bin/tdbbackup.tdbtools to provide /usr/bin/tdbbackup (tdbbackup) in auto mode
root@Samba:/home/anne#


We’ll configure and test our samba server.

Our fresh installed server uses configuration files located at /etc/samba directory.
We’ll copy this one in the same directory using mv command.
Type mv /etc/samba/smb/conf /etc/samba/smb.conf.testsamba.
You’re free in naming your smb.conf file you prefer.
Now we’ve copied our configuration file named smb.conf.testsamba.

root@Samba:/home/anne# mv /etc/samba/smb.conf /etc/samba/smb.conf.testsamba
root@Samba:/home/anne#


Now we’re able to configure our smb.conf file using Pico.

Let’s open this file, pico /etc/samba/smb.conf + enter.
You’ll see a empty file which contains nothing at this moment.

You’re free to use your own configuration instead of this example displayed below.
Type:
[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation

If you’re satisfied you can safe your file by pressing ctrl+x at once.
You’ll be asked what to do with this file, just press y.
Now press enter without changing it’s name.
Ok our smb.conf file is configured and saved in our directory /etc/samba.

At this time we’ve no shared drive yet in our samba server.
We need to create a directory in our directory /home.
Type mkdir /home/shareddrive + enter.

root@Samba:/# mkdir /home/shareddrive
root@Samba:/#


We’ve chosen shareddrive but you’re free to name it what you like.

Check this in your /home directory using ls command.
Type ls +enter.
Yes our directory shareddrive is pressent inhere.

root@Samba:/# ls /home
anne  shareddrive
root@Samba:/#


Everything is done so far so we’re ready to restart our samba server.

Every change we made needs to be written into our system by restarting our samba services.
Type /etc/init.d/samba restart + enter.

root@Samba:/# /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.
root@Samba:/#


Ok, we’ll now test our configuration we’ve made before.

Type testparm + enter.
You’ll be asked to see your dump of your service definitions.
Press y.
In this output we see our successfull deployment of our shared drive.

root@Samba:/# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section “[antwerp]“
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions

[global]
     workgroup = GNUBIZZERS
     idmap config * : backend = tdb

[antwerp]
     comment = sambainstallation
     path = /home/shareddrive
root@Samba:/#


We’re not done yet.

We need a user which will use our samba server.
We have named our samba user sysadmin.
Let’s create our user by typing useradd + username you prefere + enter.
than

Type smbpasswd -a username you’ve chosen + enter.
You’ll see New SMB password:
Type password your prefer + enter.
You’ll see Retype new SMB password:
Retype your password + enter.
Now the user sysadmin is added.

root@Samba:/# useradd sysadmin
root@Samba:/#
smbpasswd -a sysadmin
New SMB password:
Retype new SMB password:
Added user sysadmin.
root@Samba:/#


Now we’ve done everything and ready for the ultimate test.

We’ll login as sysadmin in our samba server. In fact we’ll connect into our shareddrive we’ve created before.
Type smbclient //localhost/antwerp -U sysadmin. + enter.
You’ll see Enter sysadmain’s password:
Type your password  + enter.

root@Samba:~# smbclient //192.168.0.254/antwerp -U sysadmin
Enter sysadmin’s password:
Domain=[GNUBIZZERS] OS=[Unix] Server=[Samba 3.6.6]
smb: \>


We’ve a successful logged into our shareddrive antwerp.

Let’s take a look what’s stored on that drive.
Type ls + enter.
Now we’ve a few pictures inhere displayed below.

root@Samba:~# smbclient //192.168.0.254/antwerp -U sysadmin
Enter sysadmin’s password:
Domain=[GNUBIZZERS] OS=[Unix] Server=[Samba 3.6.6]
smb: \> ls
.                                                                 D                 0    Wed Dec 18 23:40:59 2013
..                                                                D                 0    Wed Dec 18 22:57:48 2013
fancy-debian.jpg                                           1101847    Wed Dec 18 23:38:28 2013
icons.png                                                          341553    Wed Dec 18 23:36:56 2013
terminal.png                                                     79743     Wed Dec 18 23:37:40 2013
38577 blocks of size 524288. 28649 blocks available
smb: \>

If you’ve seen enough you can disconnect by typing quit + enter.


Our second test will be done using a Windows 7 based system.

Click start and type cmd than click cmd and your prompt will open.
Your CMD prompt looks like this below.
The numbers which are divided between dots repressents our samba-server’s ip address.
We’ll accomplish a connection to our samba server’s shared drive.
Type NET USE L: \\192.168.0.254\antwerp /USER:sysadmin + enter.
Type sysadmin’s password + enter.
We’re connected successfully but we’re still in our C:\ directory of Windows so w’ll change our working directory.
In Windows our shared drive is given the drive letter L.
Type L: + enter.
Our cmd prompt shows L:\ instead the default C:\
Now we’re able to see the contents by executing dir + enter.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Anne-Marie>NET USE L: \\192.168.0.254\antwerp /USER:sysadmin
Enter the password for ‘sysadmin’ to connect to ’192.168.0.254′:
The command completed susscessfully.

C:\Users\Anne-Marie>L:

L:\dir
 Volume in drive L is antwerp
 Vomume Serial Number is 622C-D244

 Directory of L:\


Picture displayed below how our real CMD look like.

You’ll see we’ve some pictures stored in our shared drive antwerp.

Samba



In our Windows system graphical user interface you’ll discover your network drive displayed on the left side below computer.

You can just click on network drive and you’ll be asked to insert sysadmin’s password to connect.

samba.gui


The contents of your drive is now accessible to explore.
Ok in our example there’s not that much stored inhere.

Samba_gui_access_shareddrive

We like to use our CMD instead of our graphical user interface.
It’s more accurate when creating directories and files.
Let’s use our cmd again and navigate to your shared drive L.
Type L: + enter.
Our purpose is to make a directory into our shared drive antwerp.
We’ll make a folder named Samba_Lessons + enter.
Type mkdir Samba-Lessons + enter.
Hmm, we’ll face a Access is denied.

L:\>mkdir Samba-Lessons
Access is denied.

L:\>

Oops it’s seems we’ve a problem here.
We’ve not write permissions here so we’ve to change it in our Samba system.

Samba_access_is_denied


Let’s go back into our configuration file smb.conf located at /etc/samba.
We’ll give us write permissions so we’ll be able to make our directories and files we like.
First you’ve to be root to perform this action.
Type su + enter.
than
Insert your password followed by enter.

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


Open your configuration file using Pico.
Type pico /etc/samba/smb.conf + enter.
The file look like below.

[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation


Now we’ll insert one more argument that will give us write permissions.

Move your cursor downwards by using your arrow keys.
Type writable=yes.
Safe your file by pressing ctrl+x
than
Enter without changing it’s name.

[global]
workgroup=gnubizzers

[antwerp]
path=/home/shareddrive
comment=sambainstallation
writable=yes


Our changes must be written by our server and must be restarted to take affect.

Type /etc/init.d/samba restart + enter.

root@Samba:/home/anne# /etc/init.d/samba restart
[ ok ] Stopping Samba daemons: nmbd smbd.
[ ok ] Starting Samba daemons: nmbd smbd.
root@Samba:/home/anne#


Ok, let’s test it.

Open your cmd one more time and navigate to L drive.
Make a directory named Samba-Lessons.
Type one more time mkdir Samba-Lessons + enter.
We face the same issue again.
We still have no write permissions after our file mocification so we need to go furter.

L:\>mkdir Samba-Lessons
Access is denied.

L:\>


Open your terminal in your Samba server.

We need to change our permissions on the shared drive itself.
Let’s take a look.
Type ls -l /home + enter.
Shareddrive is owned by user root and only this user can do everything.

anne@Samba:~$ ls -l /home
total 8
drwxr-xr-x 25 anne anne 4096 Dec 19 14:09 anne

drwxr-xr-x 
2 root root 4096 Dec 18 23:40 shareddrive
anne@Samba:~$


Login as user root by executing su + enter. Fill in your password followed by enter.
Type chmod 777 shareddrive + enter.
Check your permissions using ls -l command.
Now we must be able to write on that shared drive.

anne@Samba:~$ su
Password:
root@Samba:/home/anne# cd ..
root@Samba:/home# ls -l
total 8
drwxr-xr-x 25 anne anne 4096 Dec 24 11:43 anne
drwxr-xr-x  2 root root 4096 Dec 18 23:40 shareddrive
root@Samba:/home# chmod 777 shareddrive
root@Samba:/home# ls -l
total 8
drwxr-xr-x 25 anne anne 4096 Dec 24 11:43 anne
drwxrwxrwx  2 root root 4096 Dec 18 23:40 shareddrive
root@Samba:/home#


Let’s check this out in our Windows based machine using cmd.

Open your cmd and navigate to your L drive.
Type mkdir Samba-Lessons + enter and check this by using dir + enter.
We see here our newly created folder Samba-Lessons displayed below.

Samba_mkdir_Samba-Lessons


Now we’re able to create, change, safe and delete directories and files on the shared drive at the Samba server  from any machine connected to that drive.

When we perform such a configuration we’ll face a security breach that will affect the whole company.
The best practice is a permission management based on groups instead of users.
How to do that will be spoken in a later chapter.
We hope you’ve enjoyed this part of the servey. ;-)

Applications and commando’s locations Debian Wheezy 7

Applications and commando’s locations Debian Wheezy 7.

When we search for applications and files available in our system you don’t see such directory like Programs Files.
Our programs, files and services are divided over many directories instead of other systems.
In a Windows system you’ll find your applications in the default folder C:\Programs.Files and C:\ProgramsFiles (x86).
Our applications, services and users are stored in the root directory.The root is the start of everything in our system.
Let’s see how this looks like.
Start your terminal and navigate into the / (directory root).
The bold text in this tutorial are commando’s and its last outputs are red.
We’re in our home directory when we open our terminal.
Type cd / + enter.
Verify with pwd and you’ll see your working directory is root /.
Execute ls that reveals the subdirectories of root.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ cd /
anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls
bin   etc         lib         mnt   root  selinux  tmp  vmlinuz
boot  home        lost+found  opt   run   srv      usr
dev   initrd.img  media       proc  sbin  sys      var
anne0001@beta:/$

We can see who’s the owner of the root directory as followed.
Type ls -l + enter.
Notice the whole directory is owned by the root user.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls -l
total 84
drwxr-xr-x   2 root root  4096 Nov 13 21:39 bin
drwxr-xr-x   3 root root  4096 Nov 13 21:51 boot
drwxr-xr-x  14 root root  3160 Nov 14 11:14 dev
drwxr-xr-x 132 root root 12288 Nov 14 11:14 etc
drwxr-xr-x   3 root root  4096 Nov 13 21:54 home
lrwxrwxrwx   1 root root    32 Nov 13 20:52 initrd.img -> /boot/initrd.img-3.2.0-4-686-pae
drwxr-xr-x  16 root root  4096 Nov 13 21:38 lib
drwx——   2 root root 16384 Nov 13 20:47 lost+found
drwxr-xr-x   3 root root  4096 Nov 13 20:47 media
drwxr-xr-x   2 root root  4096 Oct  7 17:25 mnt
drwxr-xr-x   2 root root  4096 Nov 13 20:48 opt
dr-xr-xr-x 135 root root     0 Nov 14 11:12 proc
drwx——   4 root root  4096 Nov 13 21:48 root
drwxr-xr-x  19 root root   840 Nov 14 11:15 run
drwxr-xr-x   2 root root  4096 Nov 13 21:57 sbin
drwxr-xr-x   2 root root  4096 Jun 10  2012 selinux
drwxr-xr-x   2 root root  4096 Nov 13 20:48 srv
drwxr-xr-x  13 root root     0 Nov 14 11:12 sys
drwxrwxrwt  11 root root  4096 Nov 14 15:34 tmp
drwxr-xr-x  10 root root  4096 Nov 13 20:48 usr
drwxr-xr-x  12 root root  4096 Nov 13 21:45 var
lrwxrwxrwx   1 root root    28 Nov 13 20:52 vmlinuz -> boot/vmlinuz-3.2.0-4-686-pae
anne0001@beta:/$

As we said our applications are divided over different directories and files.
A incomplete list of folders that contains application files and directories displayed below.
/bin
/sbin
/usr
/usr/bin
/usr/sbin
/usr/share
/usr/local
/usr/local/games
/usr/lib
etc……

Let’s take a small guide through some of them.
In the directory /sbin you’ll find subdirectories and files that contains many commando’s used by system configuration purposes.
Important commando’s like fdisk, iptables, ifconfig, iwconfig, shutdown, etc…
Let’s see what we get here.
Type ls sbin + enter.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls sbin
acpi_available       ip                 ntfsresize
agetty               ip6tables          ntfsundelete
apm_available        ip6tables-restore  on_ac_power
badblocks            ip6tables-save     osd_login
blkid                ipmaddr            pam_tally
blockdev             iptables           pam_tally2
capsh                iptables-restore   pccardctl
cfdisk               iptables-save      pivot_root
crda                 iptunnel           plipconfig
cryptsetup           isosize            poweroff
ctrlaltdel           iw                 rarp
debugfs              iwconfig           raw
depmod               iwevent            reboot
dhclient             iwgetid            regdbdump
dhclient-script      iwlist             resize2fs
discover             iwpriv             rmmod
discover-modprobe    iwspy              route
discover-pkginstall  kbdrate            rpcbind
dmsetup              killall5           rpc.statd
dosfsck              ldconfig           rtacct
dosfslabel           logsave            rtmon
dumpe2fs             losetup            runlevel
e2fsck               lsmod              setcap
e2image              lspcmcia           sfdisk
e2label              mii-tool           shadowconfig
e2undo               mkdosfs            showmount
fdisk                mke2fs             shutdown
findfs               mkfs               slattach
fsck                 mkfs.bfs           sm-notify
fsck.cramfs          mkfs.cramfs        startpar
fsck.ext2            mkfs.ext2          startpar-upstart-inject
fsck.ext3            mkfs.ext3          start-stop-daemon
fsck.ext4            mkfs.ext4          sulogin
fsck.ext4dev         mkfs.ext4dev       swaplabel
fsck.minix           mkfs.minix         swapoff
fsck.msdos           mkfs.msdos         swapon
fsck.nfs             mkfs.ntfs          switch_root
fsck.vfat            mkfs.vfat          sysctl
fsfreeze             mkhomedir_helper   tc
fstab-decode         mkntfs             telinit
fstrim               mkswap             tune2fs
getcap               modinfo            udevadm
getpcaps             modprobe           udevd
getty                mount.fuse         umount.nfs
halt                 mount.lowntfs-3g   umount.nfs4
hdparm               mount.nfs          umount.udisks
hwclock              mount.nfs4         unix_chkpwd
ifconfig             mount.ntfs         unix_update
ifdown               mount.ntfs-3g      wipefs
ifquery              mount.vboxsf       wpa_action
ifup                 nameif             wpa_cli
init                 nfnl_osf           wpa_supplicant
insmod               ntfsclone          xtables-multi
insserv              ntfscp
installkernel        ntfslabel
anne0001@beta:/$

This long list can be overwhelming and difficult to overview.
We can avoid this by using a argument.
Our command will look like, command + path directory you prefer + /argument + wild card.
We’re interested in subdirectories and files available started by the characters if.
Let’s see what list we get.
Type ls sbin/if* + enter.
Now we see our small list filtered by if

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls sbin/if*
sbin/ifconfig  sbin/ifdown  sbin/ifquery  sbin/ifup
anne0001@beta:/$

How many directories and files are available started by f?
Our argument must focus on f followed by *.
We’re only interested in those directories started by the characters f.
Type ls sbin/f* + enter.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls sbin/f*
sbin/fdisk        sbin/fsck.ext2     sbin/fsck.minix  sbin/fsfreeze
sbin/findfs       sbin/fsck.ext3     sbin/fsck.msdos  sbin/fstab-decode
sbin/fsck         sbin/fsck.ext4     sbin/fsck.nfs    sbin/fstrim
sbin/fsck.cramfs  sbin/fsck.ext4dev  sbin/fsck.vfat
anne0001@beta:/$

Hmm to much directories and files displayed here?
Well we’ll ad one more argument to reduce our list to a minimum displayed items.
Our command will look like, command + path directory you prefer + /first argument + * + second argument.
Let’s filter our directories started by f and ended by s.
You see a short list here.
Type ls sbin/f*s + enter.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls sbin/f*s
sbin/findfs  sbin/fsck.cramfs  sbin/fsck.msdos  sbin/fsck.nfs
anne0001@beta:/$

The directory bin contains user commando’s like, cp, chmod, less, open, dir, etc…
Command ls in this directory will produce a very long list of applications en files.
Just execute ls /bin + enter if you like.
We prefer the reduced list by using another manner.
In our command we’ll use a pipe followed by a second command followed by a argument.
Our command will look like command + path directory you prefer + pipe + second command + argument.
We’re interested in command en files that contains the characters nt.
Type ls bin | grep nt + enter.
This’ll display only those items containing nt.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls bin | grep nt
findmnt
fusermount
lowntfs-3g
mount
mountpoint
ntfs-3g
ntfs-3g.probe
ntfs-3g.secaudit
ntfs-3g.usermap
ntfscat
ntfsck
ntfscluster
ntfscmp
ntfsdump_logfile
ntfsfix
ntfsinfo
ntfsls
ntfsmftalloc
ntfsmove
ntfstruncate
ntfswipe
setfont
umount
anne0001@beta:/$

We have another directory that contains a very long list of subdirectories and files.
Directory usr/share contains applications like iceweasel, java, brasero, Libreoffice, nautilus, etc…
We’ll filter our list by using our command as above.
Display the items containing lib.
Type ls usr/share | grep lib + enter.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls usr/share | grep lib
glib-2.0
libaudio2
libc-bin
libexttextcat
libgksu
libgnomekbd
libgnome-media-profiles
libgphoto2
libgweather
liblouis
libnm-gtk
libquvi-scripts
librarian
libreoffice
libsensors4
libsocialweb
libthai
libvisual-plugins-0.4
libwacom
anne0001@beta:/$

Feel free and explore more.
A few examples we’ve executed showed below.
We’ve typed ls usr/share | grep gnome + enter.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls usr/share | grep gnome
gnome
gnome-2.0
gnome-applets
gnome-background-properties
gnome-bluetooth
gnome-color-manager
gnome-control-center
gnome-dictionary
gnome-documents
gnome-games
gnome-js
gnome-mag
gnome-nettool
gnome-packagekit
gnome-panel
gnome-power-manager
gnome-screenshot
gnome-session
gnome-settings-daemon
gnome-shell
gnome-sound-recorder
gnome-sudoku
gnome-system-log
gnome-system-monitor
gnome-terminal
gnome-tweak-tool
gnome-user-share
gnome-video-effects
libgnomekbd
libgnome-media-profiles
anne0001@beta:/$

And here we have executed ls usr/share/sy* + enter.
Notice path descriptions and its contents in this output.

anne0001@beta:/$ pwd
/
anne0001@beta:/$ ls usr/share/sy*
usr/share/synaptic:
gtkbuilder  html  pixmaps

usr/share/sysvinit:
inittab  update-rc.d

usr/share/sysv-rc:
saveconfig
anne0001@beta:/$

There are much more directories and files available we have not discussed yet like the applications libraries.
Feel free to explore them and you can review the examples above.
If you don’t know what a command or application does you can execute the whatis + naam command or application name.
We’ll see how we can get the location of applications.
There are many tools we can use like whereis, locate, find and which.
Let’s see what whereis, locate, find, and which stands for.
Start in your home directory.
Type whatis whereis + enter.
The whereis is used to find the executables, location and man pages.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ whatis whereis
whereis (1)          – locate the binary, source, and manual page files for a…
anne0001@beta:~$

Repeat this command with the argument locate, find and which.
We have just discovered that locate searches in files by names.
Find w’ll search files in our folder structure and which locates user commando’s.
That’s good to know while we’re searching the locations we prefer.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ whatis whereis
whereis (1)          – locate the binary, source, and manual page files for a…
anne0001@beta:~$ whatis locate
locate (1)           – find files by name
anne0001@beta:~$ whatis find
find (1)             – search for files in a directory hierarchy
anne0001@beta:~$ whatis which
which (1)            – locate a command
anne0001@beta:~$

Let’s start our application tour and get the location of it.
Where’s whereis located?
Which command will we use to know the location of commands?
We’ve seen the meaning of which showed above.
Type which whereis + enter.
Whereis location is /usr/bin/whereis.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ which whereis
/usr/bin/whereis
anne0001@beta:~$

We know there’s a nice program called gimp.
Gimp is used to pimp your pictures and other materials.
Where’s gimp located?
Now we’ll use whereis + name of our application we prefer.
Type whereis gimp + enter.
This application uses a lot of directories displayed below.
Notice the directory that contains the man1 page of gimp.
We think the executable of gimp is located in/usr/bin/gimp but we’ll discuss thisitem later on.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ whereis gimp
gimp: /usr/bin/gimp /etc/gimp /usr/lib/gimp /usr/bin/X11/gimp /usr/share/gimp /usr/share/man/man1/gimp.1.gz
anne0001@beta:~$

We were interested in the applications displayed below.
Type whereis followed by the name you prefer.
We used the applications tomboy, vim, synaptic and iceweasel.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ whereis tomboy
tomboy: /usr/bin/tomboy /usr/lib/tomboy /usr/bin/X11/tomboy /usr/share/tomboy /usr/share/man/man1/tomboy.1.gz
anne0001@beta:~$ whereis vim
vim: /usr/bin/vim.tiny /etc/vim /usr/bin/X11/vim.tiny /usr/share/vim /usr/share/man/man1/vim.1.gz
anne0001@beta:~$ whereis synaptic
synaptic: /usr/sbin/synaptic /usr/share/synaptic /usr/share/man/man8/synaptic.8.gz
anne0001@beta:~$ whereis iceweasel
iceweasel: /usr/bin/iceweasel /etc/iceweasel /usr/lib/iceweasel /usr/bin/X11/iceweasel /usr/share/iceweasel /usr/share/man/man1/iceweasel.1.gz
anne0001@beta:~$

We can discover which files applications use and we can see what kind of extensions they’ve.
This is useful for system administrators and advanced users who like to change the behavior of applications.
Let’s see which files is used by synaptic located in /usr/share/synaptic.
We know it’s location so we’ll use the find command followed by it’s path to see our files.
Type find synaptic + /usr/share/synaptic + enter.
Be aware, this can be a very very long list.
In our example you see 2 full paths displayed containing many files.
/usr/share/synaptic/gtkbuilder and /usr/share/synaptic/pixmaps.
( incomplete list displayed below ).

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ find /usr/share/synaptic
/usr/share/synaptic
/usr/share/synaptic/gtkbuilder
/usr/share/synaptic/gtkbuilder/stock_menu_about.png
/usr/share/synaptic/gtkbuilder/dialog_update_outdated.ui
/usr/share/synaptic/gtkbuilder/dialog_proposed_new_repositories.ui
/usr/share/synaptic/gtkbuilder/window_find.ui
/usr/share/synaptic/gtkbuilder/proceed_small.png
/usr/share/synaptic/gtkbuilder/druid_repository.ui
/usr/share/synaptic/gtkbuilder/dialog_quit.ui
/usr/share/synaptic/gtkbuilder/update_small.png
/usr/share/synaptic/gtkbuilder/window_main.ui
/usr/share/synaptic/gtkbuilder/dialog_disc_label.ui
/usr/share/synaptic/gtkbuilder/window_changes.ui
/usr/share/synaptic/gtkbuilder/window_filters.ui
/usr/share/synaptic/gtkbuilder/dialog_columns.ui
/usr/share/synaptic/gtkbuilder/stock_help-book.png
/usr/share/synaptic/gtkbuilder/window_tasks.ui
/usr/share/synaptic/gtkbuilder/dialog_new_repositroy.ui
/usr/share/synaptic/gtkbuilder/window_preferences.ui
/usr/share/synaptic/gtkbuilder/dialog_task_descr.ui
/usr/share/synaptic/gtkbuilder/window_logview.ui
/usr/share/synaptic/gtkbuilder/dialog_example.ui
/usr/share/synaptic/gtkbuilder/window_about.ui
/usr/share/synaptic/gtkbuilder/window_disc_name.ui
/usr/share/synaptic/gtkbuilder/dialog_changelog.ui
/usr/share/synaptic/gtkbuilder/logo.png
/usr/share/synaptic/gtkbuilder/pref_vpaned.xpm
/usr/share/synaptic/gtkbuilder/dialog_unmet.ui
/usr/share/synaptic/gtkbuilder/window_rginstall_progress.ui
/usr/share/synaptic/gtkbuilder/dialog_download_error.ui
/usr/share/synaptic/gtkbuilder/dialog_authentication.ui
/usr/share/synaptic/gtkbuilder/dialog_update_failed.ui
/usr/share/synaptic/gtkbuilder/dialog_change_version.ui
/usr/share/synaptic/gtkbuilder/stock_filter-data-by-criteria.png
/usr/share/synaptic/gtkbuilder/distupgrade_small.png
/usr/share/synaptic/gtkbuilder/stock_filter-navigator.png
/usr/share/synaptic/gtkbuilder/window_iconlegend.ui
/usr/share/synaptic/gtkbuilder/window_setopt.ui
/usr/share/synaptic/gtkbuilder/window_details.ui
/usr/share/synaptic/gtkbuilder/window_zvtinstallprogress.ui
/usr/share/synaptic/gtkbuilder/window_summary.ui
/usr/share/synaptic/gtkbuilder/window_install_progress.ui
/usr/share/synaptic/gtkbuilder/window_rgdebinstall_progress.ui
/usr/share/synaptic/gtkbuilder/window_repositories.ui
/usr/share/synaptic/gtkbuilder/dialog_upgrade.ui
/usr/share/synaptic/gtkbuilder/upgrade_small.png
/usr/share/synaptic/gtkbuilder/cnc.png
/usr/share/synaptic/gtkbuilder/dialog_conffile.ui
/usr/share/synaptic/gtkbuilder/deb.png
/usr/share/synaptic/gtkbuilder/window_procceed.ui
/usr/share/synaptic/gtkbuilder/synaptic.xpm
/usr/share/synaptic/gtkbuilder/synaptic_mini.xpm
/usr/share/synaptic/gtkbuilder/pref_hpaned.xpm
/usr/share/synaptic/gtkbuilder/dialog_welcome.ui
/usr/share/synaptic/gtkbuilder/window_fetch.ui
/usr/share/synaptic/gtkbuilder/window_rginstall_progress_msgs.ui
/usr/share/synaptic/pixmaps
/usr/share/synaptic/pixmaps/green.png
/usr/share/synaptic/pixmaps/synaptic_32x32.xpm
/usr/share/synaptic/pixmaps/yellow.png
/usr/share/synaptic/pixmaps/red.png

We can search files by name using locate.
This will reveal full paths that contains files used by applications and services.
Our home directory is also divided over many places.
Let’s see how it look like. It’s amazing how many files are in use by Dekstop.
Type locate Desktop + enter.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne0001@beta:~$ locate Desktop
/home/anne0001/Desktop
/usr/lib/girepository-1.0/GDesktopEnums-3.0.typelib
/usr/lib/libreoffice/program/wizards/common/Desktop.py
/usr/lib/pymodules/python2.6/xdg/DesktopEntry.py
/usr/lib/pymodules/python2.6/xdg/DesktopEntry.pyc
/usr/lib/pymodules/python2.7/xdg/DesktopEntry.py
/usr/lib/pymodules/python2.7/xdg/DesktopEntry.pyc
/usr/share/man/man3/File::DesktopEntry.3pm.gz
/usr/share/perl5/File/DesktopEntry.pm
/usr/share/pyshared/xdg/DesktopEntry.py
anne0001@beta:~$

We can make a journey through our system that never ends.
Play en enjoy the possibilities you get.
We have done more examples showed below.
Notice the contents that has been saved by the user like pictures and documents.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne0001@beta:~$ locate Documents
/home/anne0001/Documents
/usr/share/dbus-1/services/org.gnome.Documents.GDataMiner.service
/usr/share/dbus-1/services/org.gnome.Documents.SearchProvider.service
/usr/share/glib-2.0/schemas/org.gnome.Documents.enums.xml
anne0001@beta:~$ locate Downloads
/home/anne0001/Downloads
/home/anne0001/Downloads/.~lock.Application_Locations.odt#
/home/anne0001/Downloads/Application_Locations.odt
/home/anne0001/Downloads/Default_Programs_Debian_Wheezy_7.odt
/home/anne0001/Downloads/new article.zip
/usr/lib/iceweasel/components/DownloadsStartup.js
/usr/lib/iceweasel/components/DownloadsUI.js
/usr/share/iceweasel/modules/DownloadsCommon.jsm
anne0001@beta:~$ locate Music
/home/anne0001/Music
/usr/share/perl/5.14.2/unicore/lib/Blk/MusicalS.pl
anne0001@beta:~$ locate Pictures
/home/anne0001/Pictures
/home/anne0001/Pictures/1.png
anne0001@beta:~$

How to find our application executables?
We can use the file command that will reveal more specific file information.
At all it can by difficult to find them but don’t give up, you’ll find your way out.
Let’s look to some of them like gimp, synaptic, libreOffice, etc….
First of all we have to know where the application is located.
Use the whereis command followed by the name application you prefer.
Type file + path + enter.
In this example you’ll see the path /usr/bin/gimp is linked to gimp-2.8.
Now you have to find out where gimp-2.8 is located by the whereis command.
Than execute file + the given path of gimp-2.8 and you’ll see this is a executable file.

anne0001@beta:~$ pwd
/home/anne0001
anne0001@beta:~$ whereis gimp
gimp: /usr/bin/gimp /etc/gimp /usr/lib/gimp /usr/bin/X11/gimp /usr/share/gimp /usr/share/man/man1/gimp.1.gz
anne0001@beta:~$ file /usr/bin/gimp
/usr/bin/gimp: symbolic link to `gimp-2.8′
anne0001@beta:~$ whereis gimp-2.8
gimp-2: /usr/bin/gimp-2.8 /usr/bin/X11/gimp-2.8
anne0001@beta:~$ file /usr/bin/gimp-2.8
/usr/bin/gimp-2.8: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x4be6b5c0c3f262db1fdb5a9eca1ebc38b62934b9, stripped
anne0001@beta:~$

Let’s see some more executables files of our selected applications.
We have chosen for Synaptic, vim, tomboy. You’re free in your choices of applications.
By Synaptic we’re in lucky, the first path contains our executable file.
Type the bold text displayed here.

anne0001@beta:~$ whereis synaptic
synaptic: /usr/sbin/synaptic /usr/share/synaptic /usr/share/man/man8/synaptic.8.gz
anne0001@beta:~$ file /usr/sbin/synaptic
/usr/sbin/synaptic: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x1dbc721d9863f48b1e7f762848f289664abb946d, stripped
anne0001@beta:~$

Let’s look which location tomboy have.

anne0001@beta:~$ whereis tomboy
tomboy: /usr/bin/tomboy /usr/lib/tomboy /usr/bin/X11/tomboy /usr/share/tomboy /usr/share/man/man1/tomboy.1.gz
anne0001@beta:~$ file /usr/bin/tomboy
/usr/bin/tomboy: a /usr/bin/env bash script, ASCII text executable
anne0001@beta:~$ file /usr/lib/tomboy
/usr/lib/tomboy: directory
anne0001@beta:~$ file /usr/bin/X11/tomboy
/usr/bin/X11/tomboy: a /usr/bin/env bash script, ASCII text executable
anne0001@beta:~$ file /usr/share/tomboy
/usr/share/tomboy: directory
anne0001@beta:~$ file  /usr/share/man/man1/tomboy.1.gz
/usr/share/man/man1/tomboy.1.gz: gzip compressed data, from Unix, max compression
anne0001@beta:~$

Sometimes it’s handy to find locations of different applications at once.
In this example we’ll use synaptic and vim.
Our output shows two executable files of synaptic and vim.

anne0001@beta:~$ whereis synaptic
synaptic: /usr/sbin/synaptic /usr/share/synaptic /usr/share/man/man8/synaptic.8.gz
anne0001@beta:~$ whereis vim
vim: /usr/bin/vim.tiny /etc/vim /usr/bin/X11/vim.tiny /usr/share/vim /usr/share/man/man1/vim.1.gz
anne0001@beta:~$ file /usr/sbin/synaptic /usr/bin/vim.tiny
/usr/sbin/synaptic: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x1dbc721d9863f48b1e7f762848f289664abb946d, stripped
/usr/bin/vim.tiny:  ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x18ec027c27af8f3fdc812003fc46aaeaf4c28814, stripped
anne0001@beta:~$

Now we’ve a good idea about applications and it’s files locations.
Keep in mind that this tutorial showed a small amount of possibilities.
Next time we’ll show you how we can open applications using our terminal.

Some handy tips you can use while you’re on a journey through this fancy system.
For very long command use the copy and past feature available in your terminal.
You can review the previous tutorial “Directory and File Management using Terminal Debian.
(
http://gnubizz2.wordpress.com/2013/11/06/directory-and-file-management-using-terminal-debian/ ).

Need some more help about commands and how to use applications?
You can advise –help, man and info pages.
Visit our tutorial “Important built-in information in Debian Wheezy 7 system.”
(
http://gnubizz2.wordpress.com/2013/10/30/important-built-in-information-in-debian-wheezy-7-system/).

We hope you have enjoyed it.
If you have any doubts or questions you can leave a comment.
See you next time. ;-)

 

Directory and File Management using Terminal Debian.

Directory & File Management using Terminal Debian.

Our system is built up with directories and files. We’ll focus this discussion in using our home directory.
Most users are working in this directory.
We like to have our own data, documents, pictures, video’s, favorites, etc….
Our system has created a default folder structure as our home directory. It’s look like this example below.
Type in you terminal the bold text during this tutorial.
First of all we must know where we’re working from. Let’s take a look.
Type pwd + enter.
You can see anne’s working directory /home/anne.
Type ls + enter.
The sub directories structure displayed here.

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

In the past we discussed the cd command to navigate through our system.
If you like you can review “Terminal exploration in home directory Debian Wheezy 7” tutorial.
In our example we have already made files in /Documents. Let’s take a look.
Type cd Documents+ enter.
Which files contains the directory Documents?
Type ls -l + enter.
We have files in our directory /Documents.
Notice the extension of the files.
Sometimes it’s not clear to see the extension of files.
We can see the extension with the command file.
Type file + name of the file + enter.
The file is a OpenDocument Text extension displayed in our example.

anne@alfa:~$ cd Documents
anne@alfa:~/Documents$ ls -l
total 44
-rw-r–r– 1 anne anne 24809 Oct 29 19:22 AJourneyIntoTheHeartOfDebianWheezy7..odt
-rw-r–r– 1 anne anne 13496 Oct 25 12:40 TerminalExplorationInHomeDirectoryDebianWheezy7.odt
anne@alfa:~/Documents$ file AJourneyIntoTheHeartOfDebianWheezy7..odt
AJourneyIntoTheHeartOfDebianWheezy7..odt: OpenDocument Text
anne@alfa:~/Documents$

TIP:
Sometimes files can have long names You don’t need to type the whole name, just copy and past it into  your terminal.
You can’t use the ctrl + c and ctrl + v, they’ve other meanings in our terminal!
Highlight the name of the file you prefer and richt click on it, choice copy.
Than type your command + space + richt click and choice paste + enter.
Example displayed below.

Highlight file, right click and click copy.

Capture

Type file + space + right click on the cursor and click paste followed by enter.

Capture1

Here you’ll see the OpenDocument Text extension showed below.

Capture2

We’ve another ls combination to view submaps or files in our home directory at once.
Review the help or man pages for more ls combinations available.
Start from your home directory ~/ (/home/anne)
Type ls -lR + enter.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ ls -lR
.:
total 32
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Desktop
drwxr-xr-x 2 anne anne 4096 Nov  3 13:02 Documents
drwxr-xr-x 2 anne anne 4096 Oct 26 17:58 Downloads
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Music
drwxr-xr-x 2 anne anne 4096 Nov  2 01:02 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

. /Desktop:
total 0

. /Documents:
total 68
-rw-r–r– 1 anne anne 24809 Oct 29 19:22 AJourneyIntoTheHeartOfDebianWheezy7..odt
-rw-r–r– 1 anne anne 23685 Nov  2 16:23 DirectoryFileManagementUseTerminalDebianWheezy7..odt
-rw-r–r– 1 anne anne 13496 Oct 25 12:40 TerminalExplorationInHomeDirectoryDebianWheezy7.odt

. /Downloads:
total 0

. /Music:
total 0

. /Pictures:
total 276
-rw-r–r– 1 anne anne  17006 Oct 24 23:00 command1.png
-rw-r–r– 1 anne anne 107714 Oct 18 20:15 debian.png
-rw-r–r– 1 anne anne 149384 Oct 29 19:15 TOP.png

. /Public:
total 0

. /Templates:
total 0

. /Videos:
total 0
anne@alfa:~$

Now we’ll start to create our own directories and files.
Pay attention while naming directories and files! Try to avoid spaces. This will give erro’s like “no such file or directory.”
Let’s say we’ll create a dircetory named gnubizz in our home directory.
For more info about mdir you can advice the man, –help pages.
If you’re not sure about your working directory use the pwd or ls command.
Our working directory must be /home/anne.
Type mkdir + name of directory + enter.
As we can see the new directory Gnubizz.

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

We’ll make another directory in the Gnubizz.
Go to Gnubizz with the cd command ( cd Gnubizz ).
Create a directory named OpenSource.
Type mkdir + OpenSource + enter.
After that return to your home directory by the syntax cd ~.
To view our subdirectories in our home folder execute ls -lR.
Notice the directory Gnubizz contains the sub directory OpenSource.
The directory OpenSource is a child of the parent directory Gnubizz.

anne@alfa:~$ cd Gnubizz
anne@alfa:~/Gnubizz$ mkdir OpenSource
anne@alfa:~/Gnubizz$ ls
OpenSource
anne@alfa:~/Gnubizz$ cd ~
anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls -lR
.:
total 36
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Desktop
drwxr-xr-x 2 anne anne 4096 Nov  3 13:02 Documents
drwxr-xr-x 2 anne anne 4096 Oct 26 17:58 Downloads
drwxr-xr-x 3 anne anne 4096 Nov  3 14:59 Gnubizz
drwxr-xr-x 2 anne anne 4096 Oct 17 16:25 Music
drwxr-xr-x 2 anne anne 4096 Nov  2 01:02 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

. /Desktop:
total 0

. /Documents:
total 68
-rw-r–r– 1 anne anne 24809 Oct 29 19:22 AJourneyIntoTheHeartOfDebianWheezy7..odt
-rw-r–r– 1 anne anne 23685 Nov  2 16:23 DirectoryFileManagementUseTerminalDebianWheezy7..odt
-rw-r–r– 1 anne anne 13496 Oct 25 12:40 TerminalExplorationInHomeDirectoryDebianWheezy7.odt

. /Downloads:
total 0

. /Gnubizz:
total 4
drwxr-xr-x 2 anne anne 4096 Nov  3 14:59 OpenSource

. /Gnubizz/OpenSource:
total 0

. /Music:
total 0

. /Pictures:
total 276
-rw-r–r– 1 anne anne  17006 Oct 24 23:00 command1.png
-rw-r–r– 1 anne anne 107714 Oct 18 20:15 debian.png
-rw-r–r– 1 anne anne 149384 Oct 29 19:15 TOP.png

. /Public:
total 0

. /Templates:
total 0

. /Videos:
total 0
anne@alfa:~$

We we’ll create more directories at once in our directory Gnubizz.
Create two directories named Gnubizz1 and Gnubizz2. Go to directory Gnubizz.
The working directory must by /home/anne/Gnubizz. By any doubts check it by pwd command.
Execute ls and you’ll see three directories Gnubizz1, Gnubizz2 and OpenSource displayed below
Type mkdir Gnubizz1 + space + Gnubizz2 + enter.

anne@alfa:~$ cd Gnubizz
anne@alfa:~/Gnubizz$ pwd
/home/anne/Gnubizz
anne@alfa:~/Gnubizz$ ls
OpenSource
anne@alfa:~/Gnubizz$ mkdir Gnubizz1 Gnubizz2
anne@alfa:~/Gnubizz$ ls
Gnubizz1  Gnubizz2  OpenSource
anne@alfa:~/Gnubizz$

We have seen how we create directories but sometimes we need to rename them.
We’ll rename the OpenSource to OpenSourceComputing.
We’re still in our Gnubizz directory that contains three maps, Gnubizz1  Gnubizz2  OpenSource.
Verify with ls and you w’ll see the name of the directory
OpenSource has changed into OpenSourceComputing.
Type mv + OpenSource + OpenSourceComputing + enter.

anne@alfa:~/Gnubizz$ pwd
/home/anne/Gnubizz
anne@alfa:~/Gnubizz$ ls
Gnubizz1  Gnubizz2  OpenSource
anne@alfa:~/Gnubizz$ mv OpenSource OpenSourceComputing
anne@alfa:~/Gnubizz$ ls
Gnubizz1  Gnubizz2  OpenSourceComputing
anne@alfa:~/Gnubizz$

We’re now able to make and change names of our directories.
Sometime we move them to another directory we like.
We’ll use the same command mv. We w’ll move directories Gnubizz1 and Gnubizz2 into our
OpenSourceComputing directory. First of all we need to known our path to move them.
Let’s see where the directory Gnubizz is located.
Start at your home directory and verify with pwd, /home/anne.
Execute ls to view your directory Gnubizz.
To find out the path of Gnubizz use locate command.
Now you w’ll see the path and submap path aswell of Gnubizz.
Before move directories we need to know the source path and the destination path of our directory.
Our syntax is as followed, mv + source directory + destination directory.
Typ locate + naam of directory + enter.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Gnubizz/Gnubizz1
/home/anne/Gnubizz/Gnubizz2
/home/anne/Gnubizz/OpenSource
anne@alfa:~$

Type mv ~/Gnubizz/Gnubizz1 + space + ~/Gnubizz/OpenSourceComputing + enter.
Verify with ls to see if Gnubizz1 has moved into the directory OpenSourceComputing.
Type ls Gnubizz/OpenSourceComputing.+ enter.
Notice Gnubizz1 has moved into OpenSourceComputing.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Gnubizz/Gnubizz1
/home/anne/Gnubizz/Gnubizz2
/home/anne/Gnubizz/OpenSource
anne@alfa:~$ mv ~/Gnubizz/Gnubizz1 ~/Gnubizz/OpenSourceComputing
anne@alfa:~$ ls Gnubizz/OpenSourceComputing
Gnubizz1
anne@alfa:~$

We can use the another description of our path to move our second directory Gnubizz2 into OpenSourceComputing.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Gnubizz/Gnubizz1
/home/anne/Gnubizz/Gnubizz2
/home/anne/Gnubizz/OpenSource
anne@alfa:~$ mv /home/anne/Gnubizz/Gnubizz2 /home/anne/Gnubizz/OpenSourceComputing
anne@alfa:~$ ls /Gnubizz/OpenSourceComputing
Gnubizz1  Gnubizz2
anne@alfa:~$

Sometimes we can have errors when we check this out.
The best way to check is use the ls command followed by the full path. In this example.
Type ls /home/anne/Gnubizz/OpenSourceComputing + enter.
Now our OpenSourceComputing contains two subdirectories Gnubizz1 and Gnubizz2.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Gnubizz/Gnubizz1
/home/anne/Gnubizz/Gnubizz2
/home/anne/Gnubizz/OpenSource
anne@alfa:~$ ls /home/anne/Gnubizz/OpenSourceComputing
Gnubizz1  Gnubizz2
anne@alfa:~$

The other description to the full path

anne@alfa:~$ ls ~/Gnubizz/OpenSourceComputing
Gnubizz1  Gnubizz2
anne@alfa:~$

We have seen how we can view, make, change names and move directories.
We’ll copy the whole directory Gnubizz on our Desktop.
As you have seen our directory Gnubizz contains subdirectory displayed below.
Type ls -R Gnubizz + enter.

anne@alfa:~$ ls -R Gnubizz
Gnubizz:
OpenSourceComputing

Gnubizz/OpenSourceComputing:
Gnubizz1  Gnubizz2

Gnubizz/OpenSourceComputing/Gnubizz1:

Gnubizz/OpenSourceComputing/Gnubizz2:

Now w’ll copy the directory Gnubizz and its contents on our Desktop by using the cp command.
You can advice the cp man or help pages to reveal more info.
Start at your home directory /home/anne.
We must know the source and destination path while using the cp command.
The syntax is as followed cp + source directory path + space  + destination directory path.
The -R will copy the whole directory into our Desktop. Notice the directory Gnubizz is copied into our Desktop.
Now we’ve two same Gnubizz directories, one in our Desktop and the other one in our home directory.
Type cp -R ~/Gnubizz ~/Desktop + enter.

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

Check this with the command ls from your home directory.
Notice you’ll see Gnubizz and it’s contents twice by Desktop and Your home directory.

anne@alfa:~$ ls -R
.:
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos

. /Desktop:
Gnubizz

. /Desktop/Gnubizz:
OpenSourceComputing

. /Desktop/Gnubizz/OpenSourceComputing:
Gnubizz1  Gnubizz2

. /Desktop/Gnubizz/OpenSourceComputin /Gnubizz1:

. /Desktop/Gnubizz/OpenSourceComputing/Gnubizz2:

. /Documents:
AJourneyIntoTheHeartOfDebianWheezy7..odt
DirectoryFileManagementUseTerminalDebianWheezy7..odt
TerminalExplorationInHomeDirectoryDebianWheezy7.odt

. /Downloads:

. /Gnubizz:
OpenSourceComputing

. /Gnubizz/OpenSourceComputing:
Gnubizz1  Gnubizz2

. /Gnubizz/OpenSourceComputing/Gnubizz1:

. /Gnubizz/OpenSourceComputing/Gnubizz2:

. /Music:

. /Pictures:
command1.png  debian.png  TOP.png

. /Public:

. /Templates:

. /Videos:
anne@alfa:~$

In our directories we have files. This file can be everything you like, video’s, documents, foto’s, songs etc…..
We have some files stored in our directory Documents and Pictures.
Start at your home directory.
Notice the file extensions stored at Documents and Pictures.
The pictures have the extension png and de documents odt.
Type ls -R + enter.

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

. /Desktop:
Gnubizz

. /Desktop/Gnubizz:
OpenSourceComputing

. /Desktop/Gnubizz/OpenSourceComputing:
Gnubizz1  Gnubizz2

. /Desktop/Gnubizz/OpenSourceComputing/Gnubizz1:

. /Desktop/Gnubizz/OpenSourceComputing/Gnubizz2:

. /Documents:
AJourneyIntoTheHeartOfDebianWheezy7..odt  A.odt  TerminalExplorationInHomeDirectoryDebianWheezy7.odt

. /Downloads:

. /Gnubizz:
OpenSourceComputing

. /Gnubizz/OpenSourceComputing:
Gnubizz1  Gnubizz2

. /Gnubizz/OpenSourceComputing/Gnubizz1:

. /Gnubizz/OpenSourceComputing/Gnubizz2:

. /Music:

. /Pictures:
command1.png  debian.png  TOP.png

. /Public:

. /Templates:

. /Videos:
anne@alfa:~$

w’ll make a text file using Pico in our terminal.
Go to the subdirectory Gnubizz in the directory Desktop.
To find the right path to Gnubizz you can use the command locate.
The path is /home/anne/Desktop/Gnubizz.
Type cd /home/anne/Desktop/Gnubizz

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Desktop/Gnubizz
/home/anne/Desktop/Gnubizz/OpenSourceComputing
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
/home/anne/Gnubizz/OpenSourceComputing
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~$ cd /home/anne/Desktop/Gnubizz
anne@alfa:~/Desktop/Gnubizz$

Our purpose is making a file into our Gnubizz directory.
Open Pico in your terminal and type some text you like.
Type pico + enter.

1

When you’re done editing you can press ctrl + x.
After ctrl + x you w’ll be asked what you want. If you like to save your file type Y.
If you press N your file w’ll be lost.

2

You will be asked to fill in your file name. Type your filename and press enter.
We’ve just created our file in Gnubizz.

3

Check in your Gnubizz directory using the ls commad.
Type ls + enter or if you prefer ls -l + enter.
Notice the new file in Gnubizz. In our example you w’ll see  our file named GnubizzSite.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Desktop/Gnubizz
/home/anne/Desktop/Gnubizz/OpenSourceComputing
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
/home/anne/Gnubizz/OpenSourceComputing
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~$ cd /home/anne/Desktop/Gnubizz
anne@alfa:~/Desktop/Gnubizz$ pico
anne@alfa:~/Desktop/Gnubizz$ ls
GnubizzSite  OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$ ls -l
total 8
-rw-r–r– 1 anne anne  450 Nov  5 18:43 GnubizzSite
drwxr-xr-x 4 anne anne 4096 Nov  4 16:09 OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$

Check the extension of our new file.
Our file Gnubizzsite has the extension ASCII text displayed below.
Type file GnubizzSite + enter.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Desktop/Gnubizz
/home/anne/Desktop/Gnubizz/OpenSourceComputing
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
/home/anne/Gnubizz/OpenSourceComputing
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~$ cd /home/anne/Desktop/Gnubizz
anne@alfa:~/Desktop/Gnubizz$ pico
anne@alfa:~/Desktop/Gnubizz$ ls
GnubizzSite  OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$ ls -l
total 8
-rw-r–r– 1 anne anne  450 Nov  5 18:43 GnubizzSite
drwxr-xr-x 4 anne anne 4096 Nov  4 16:09 OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$ file GnubizzSite
GnubizzSite: ASCII text
anne@alfa:~/Desktop/Gnubizz$

We’ll copy our file GnubizzSite to our subdirectories Gnubizz1 and Gnubizz2 in our Desktop.
Start at your Gnubizz directory and execute the locate command to display the path.
Type locate + Gnubizz1 + space + Gnubizz2 + enter to reveal the full path.
Copy our GnubizzSite file into our two subdirectories Gnubizz1 and Gnubizz2.
Type cp GnubizzSite + space + /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
Repeat this command for the second directory.
You can use your arrow keys on your board to get your command back again.
Use your up arrow key and only change the 1 of Gbubizz1 to 2 like this:
cp GnubizzSite + space + /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
Now we’ve three files named GnubizzSite in our dirctories, Gnubizz, Gnubizz1 and Gnubizz2 located in our Desktop.
Check this as followed. Type
ls /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
and
ls /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
and one more time.
type ls

anne@alfa:~/Desktop/Gnubizz$ locate Gnubizz1 Gnubizz2
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~/Desktop/Gnubizz$ ls
GnubizzSite  OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$ cp GnubizzSite /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
anne@alfa:~/Desktop/Gnubizz$ cp GnubizzSite /home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~/Desktop/Gnubizz$ ls/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
GnubizzSite
anne@alfa:~/Desktop/Gnubizz$ ls/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
GnubizzSite
anne@alfa:~/Desktop/Gnubizz$ ls
GnubizzSite  OpenSourceComputing
anne@alfa:~/Desktop/Gnubizz$

Let’s open our file GnubizzSite in the directory Gnubizz1 in our Desktop. Start in the Gnubizz1 directory.
Type cd/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
Open your file GnubizzSite with pico.
Type Pico GnubizzSite
Modify your file by typing more text you like and save your file using the same name.
How to save your file you can follow the same procedure as the description above.
When you’ve done your modification press ctrl + x and than Y.
Keep the name GnubizzSite and press enter.
Our file is saved again after the modification.

4

We have made, moved, modified, and saved directories and files.
Now we’ll remove our directory Gnubizz in our home directory.
As you know we have two of them, one in our Desktop and one in our Home directory.
Start in the home directoy /home/anne.
Type ls if you’re not sure before removing directories or files.
Be aware when you remove it you can’t get it back!
Type rmdir Gnubizz + enter.
Notice we have a error, we can’t remove it because this directory contains subdirectories. (not displayed here!!)
We we’ll navigate through this directory and remove them.
Let’s do it ;-).
Type cd /home/anne/Gnubizz/OpenSourceComputing
Now we’re in OpenSourceComputing that contains the Gnubizz1 and Gnubizz2. Remove them.
Type rmdir Gnubizz1 Gnubizz2
Verify it with the ls command to see there’re gone now.
Type cd ..
We’re in the directory Gnubizz that contain the directory OpenSourceComputing.
Type rmdir OpenSourceComputing
Check it with ls and you w’ll see it’s gone.
Type cd .. again to go into you home directory.
Verify with ls command.
Type rmdir Gnubizz
Type one more time ls and you w’ll see everything is gone.

anne@alfa:~$ pwd
/home/anne
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ locate Gnubizz
/home/anne/Gnubizz
/home/anne/Desktop/Gnubizz
/home/anne/Desktop/Gnubizz/OpenSourceComputing
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Desktop/Gnubizz/OpenSourceComputing/Gnubizz2
/home/anne/Gnubizz/OpenSourceComputing
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz1
/home/anne/Gnubizz/OpenSourceComputing/Gnubizz2
anne@alfa:~$ cd /home/anne/Gnubizz/OpenSourceComputing
anne@alfa:~/Gnubizz/OpenSourceComputing$ ls
Gnubizz1  Gnubizz2
anne@alfa:~/Gnubizz/OpenSourceComputing$ rmdir Gnubizz1 Gnubizz2
anne@alfa:~/Gnubizz/OpenSourceComputing$ ls
anne@alfa:~/Gnubizz/OpenSourceComputing$ cd ..
anne@alfa:~/Gnubizz$ ls
OpenSourceComputing
anne@alfa:~/Gnubizz$ rmdir OpenSourceComputing
anne@alfa:~/Gnubizz$ ls
anne@alfa:~/Gnubizz$ cd ..
anne@alfa:~$ ls
Desktop  Documents  Downloads  Gnubizz  Music  Pictures  Public  Templates  Videos
anne@alfa:~$ rmdir Gnubizz
anne@alfa:~$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
anne@alfa:~$

Ok at the first time it’s hard to understand but over time you’ll get used to it.
Just try and play and you will loved it.

This was our journey through home directory.
By any doubts our questions don’t hesitate to leave a comment.
We hope you’ve enjoyed it.
See you next time. ;-)

Important built-in information in Debian Wheezy 7 system.

Important built-in information in Debian Wheezy 7 system.

  • Our purpose is how we can grab important information available in our system.
    We can guide us trough many available built-in tools. It’s impossible to remember all commands and what functions they have.
    The system give us the opportunity to rediscover forgotten things.
    When you’ve a question you can use the whatis command, the answer will be displayed.
    Lets see what’s happen if you execute the command without any option.

    The system will ask you what you want to know.
    Type whatis + enter.

anne@alfa:~$ whatis
whatis what?
anne@alfa:~$

  • Retype your whatis command + option you willing to know about.
    Example 1: Type whatis + uptime + enter.

anne@alfa:~$ whatis uptime
uptime (1)           – Tell how long the system has been running.
anne@alfa:~$

  • Example 2: Type whatis + date + enter.

anne@alfa:~$ whatis date
date (1)             – print or set the system date and time
anne@alfa:~$

  • If you dont know what a command stands for you can use the same whatis command + name programm or syntax.
    Let’s use the ls as option.
    Type whatis + ls +enter.

anne@alfa:~$ whatis ls
ls (1)               – list directory contents
anne@alfa:~$

  • Let’s ask what the dir represents.
    Type whatis + dir + enter.

anne@alfa:~$ whatis dir
dir (1)              – list directory contents
anne@alfa:~$

  • The whatis command is useful but sometimes we want to know more about the syntax. We can execute the specified command + –help.
    Example 1: Type ls –help + enter.
    (below a incomplete help page displayed)

anne@alfa:~$ ls –help
Usage: ls [OPTION]… [FILE]…
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor –sort is specified.

Mandatory arguments to long options are mandatory for short options too.
-a, –all                  do not ignore entries starting with .
-A, –almost-all           do not list implied . and ..
–author               with -l, print the author of each file
-b, –escape               print C-style escapes for nongraphic characters
–block-size=SIZE      scale sizes by SIZE before printing them.  E.g.,
`–block-size=M’ prints sizes in units of
1,048,576 bytes.  See SIZE format below.

  • We can consult man pages in our terminal. Man pages describe how to use syntax combinations.
    This can be overwhelming when you open a man page.
    Use the ls option in this example.
    Type man ls + enter.
    (below a incomplete man page displayed)
    Press q to leave man page!

anne@alfa:~$ man ls
SYNOPSIS
ls [OPTION]… [FILE]…

DESCRIPTION
List information about the FILEs (the current directory by default).  Sort entries alphabeti‐
cally if none of -cftuvSUX nor –sort is specified.

Mandatory arguments to long options are mandatory for short options too.

-a, –all
do not ignore entries starting with .

-A, –almost-all
do not list implied . and ..

–author
with -l, print the author of each file

-b, –escape
print C-style escapes for nongraphic characters

  • The man pages can be very difficult to read so we can use another tool info.
    Sometimes you have a better description which the info command. Some info pages are quite hard to read as well like man pages do. The best way is to try the differences between them and search the best suitable.
    Let’s guide us trough a info page about man.
    Type info man + enter.
    (below a incomplete info page displayed)
    Press q to exit info list!

anne@alfa:~$ info man
MAN(1)                        Manual pager utils                        MAN(1)

NAME
man – an interface to the on-line reference manuals

SYNOPSIS
man  [-C  file]  [-d]  [-D]  [--warnings[=warnings]]  [-R encoding] [-L
locale] [-m system[,...]] [-M path] [-S list]  [-e  extension]  [-i|-I]
[--regex|--wildcard]   [--names-only]  [-a]  [-u]  [--no-subpages]  [-P
pager] [-r prompt] [-7] [-E encoding] [--no-hyphenation] [--no-justifi‐
cation]  [-p  string]  [-t]  [-T[device]]  [-H[browser]] [-X[dpi]] [-Z]
[[section] page …] …
man -k [apropos options] regexp …
man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term …
man -f [whatis options] page …
man -l [-C file] [-d] [-D] [--warnings[=warnings]]  [-R  encoding]  [-L
locale]  [-P  pager]  [-r  prompt]  [-7] [-E encoding] [-p string] [-t]
[-T[device]] [-H[browser]] [-X[dpi]] [-Z] file …
man -w|-W [-C file] [-d] [-D] page …
man -c [-C file] [-d] [-D] page …
man [-hV]

DESCRIPTION
man is the system’s manual pager. Each page argument given  to  man  is
normally  the  name of a program, utility or function.  The manual page
associated with each of these arguments is then found and displayed.

  • We can use another feature named apropos. This act as a search engine for man pages and descriptions.
    Here you’ll find a long alphabetic list.
    First we have performed the command whatis apropos to verify it’s meaning. Let’s use the option ls.
    Type apropos + ls + enter.
    (below a incomplete aprops list displayed)

anne@alfa:~$ whatis apropos
apropos (1)          – search the manual page names and descriptions

anne@alfa:~$ apropos ls
alsamixer (1)        – soundcard mixer for ALSA soundcard driver, with ncurses interface
amidi (1)            – read from and write to ALSA RawMIDI ports
amixer (1)           – command-line mixer for ALSA soundcard driver
aplay (1)            – command-line sound recorder and player for ALSA soundcard driver
arecord (1)          – command-line sound recorder and player for ALSA soundcard driver
aseqdump (1)         – show the events received at an ALSA sequencer port
aseqnet (1)          – ALSA sequencer connectors over network
assert (3)           – abort the program if assertion is false
auth_destroy (3)     – library routines for remote procedure calls
authnone_create (3)  – library routines for remote procedure calls
authunix_create (3)  – library routines for remote procedure calls
authunix_create_default (3) – library routines for remote procedure calls
backtrace_symbols (3) – support for application self-debugging
backtrace_symbols_fd (3) – support for application self-debugging
blockdev (8)         – call block device ioctls from the command line

  • Some command has more than one man page available.
    In this example we’ll use the uname option. Here are two man pages available.
    Type man -f uname.

anne@alfa:~$ man -f uname
uname (1)            – print system information
uname (2)            – get name and information about current kernel
anne@alfa:~$

  • We know there are two uname man pages available. Let’s discover man page 2. Section 1 will be displayed as default when you execute man uname.
    You must insert the section between man and the option you like. In this example we’ll use  (command) man + (section) 2 + (option) uname.
    (below a incomplete uname (2) man page displayed)
    Press q to leave man page.
    Type man + 2 + uname + enter.

anne@alfa:~$ man 2 uname
UNAME(2)                            Linux Programmer’s Manual                            UNAME(2)

NAME
uname – get name and information about current kernel

SYNOPSIS
#include <sys/utsname.h>

int uname(struct utsname *buf);

DESCRIPTION
uname() returns system information in the structure pointed to by buf.  The utsname struct
is defined in <sys/utsname.h>:

struct utsname {
char sysname[];    /* Operating system name (e.g., “Linux”) */
char nodename[];   /* Name within “some implementation-defined
network” */
char release[];    /* Operating system release (e.g., “2.6.28″) */
char version[];    /* Operating system version */
char machine[];    /* Hardware identifier */
#ifdef _GNU_SOURCE
char domainname[]; /* NIS or YP domain name */
#endif
};

  • Try another option traceroute. In this example you’ll have two man pages available.
    Type man -f traceroute

anne@alfa:~$ man -f traceroute
tcptraceroute (8)    – print the route packets trace to network host
traceroute (1)       – print the route packets trace to network host
anne@alfa:~$

  • Now we’re able to search help items we’ll discover important information.
    Very useful for system administrators and people who’re interested how the system looks like.
    Let’s start the simple way to get used to it.
    Let’s show the date.

    Type date + enter.

anne@alfa:~$ date
Sat Oct 26 20:21:50 CEST 2013
anne@alfa:~$

  • If you preference the calendar format use the cal command.
    Type cal + enter.

anne@alfa:~$ cal
October 2013
Su Mo Tu We Th Fr Sa
1  2  3  4  5
6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31

anne@alfa:~$

  • How long is our system running? Use command uptime.
    This command is measured at 20:47:49  and you can see our system is running about 2:51 hours.
    Notice 2 users are logged, one user is myself and the other one is the root user on the background.
    Type Uptime + enter.

anne@alfa:~$ uptime
20:47:49 up  2:51,  2 users,  load average: 0.00, 0.03, 0.05
anne@alfa:~$

  • I’m interested in the login history off all users. This can be useful by system administrators to see what happens by users.
    To reveal interested information about last  you can view the last info page.
    Let’s look who has logged into the system by using the command last.
    Type last + enter.

anne@alfa:~$ last
anne         pts/0                :0.0                           Wed Oct 30 12:04   still logged in
anne         tty7                  :0                               Wed Oct 30 12:04   still logged in
(unknown tty7                :0                              Wed Oct 30 12:04 – 12:04  (00:00)
reboot   system boot  3.2.0-4-amd64       Wed Oct 30 12:04 – 14:25  (02:20)
anne        pts/0                :0.0                           Tue Oct 29 23:27 – 01:02  (01:35)
root         pts/1                :0.0                           Tue Oct 29 23:18 – 23:19  (00:01)
anne        pts/0                :0.0                           Tue Oct 29 23:15 – 23:17  (00:01)
anne        pts/0                :0.0                           Tue Oct 29 14:56 – 19:22  (04:26)
anne        tty7                   :0                              Tue Oct 29 14:41 – 01:05  (10:23)
(unknown tty7                :0                              Tue Oct 29 14:40 – 14:41  (00:01)

  • Let’s take a look at het system properties. We can use the uname command.
    What’s uname? Execute whatis command and let’s find out  what the uname commmand does.
    Type uname + enter.

anne@alfa:~$ whatis uname
uname (1)            – print system information
uname (2)            – get name and information about current kernel
anne@alfa:~$ uname
Linux
anne@alfa:~$

  • View uname help page to reveal more options.
    Type uname –help + enter.

anne@alfa:~$ uname –help
Usage: uname [OPTION]…
Print certain system information.  With no OPTION, same as -s.

-a, –all                print all information, in the following order,
except omit -p and -i if unknown:
-s, –kernel-name        print the kernel name
-n, –nodename           print the network node hostname
-r, –kernel-release     print the kernel release
-v, –kernel-version     print the kernel version
-m, –machine              print the machine hardware name
-p, –processor            print the processor type or “unknown”
-i, –hardware-platform  print the hardware platform or “unknown”
-o, –operating-system   print the operating system
–help     display this help and exit
–version  output version information and exit

Report uname bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/&gt;
General help using GNU software: <http://www.gnu.org/gethelp/&gt;
For complete documentation, run: info coreutils ‘uname invocation’
anne@alfa:~$

  • We have a lot of options available so let’s try it and see which information will appears.
    In my opinion you can get the best information while using the -a option.
    Below a example with all options used.
    Type uname + option + enter.

anne@alfa:~$ uname -a
Linux alfa 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
anne@alfa:~$ uname -s
Linux
anne@alfa:~$ uname -n
alfa
anne@alfa:~$ uname -r
3.2.0-4-amd64
anne@alfa:~$ uname -v
#1 SMP Debian 3.2.51-1
anne@alfa:~$ uname -m
x86_64
anne@alfa:~$ uname -p
unknown
anne@alfa:~$ uname -i
unknown
anne@alfa:~$ uname -o
GNU/Linux

  • Here another interesting option which give us more information.
    In the past we’ve discussed the ls command used to display contents of directories and files.

    We can use the ls command to gather more system information.
    We will discuss only the most useful options here. To show ls options available by pressing the tab twice.
    You can see the available ls options below.
    Type ls + two times tab key.

anne@alfa:~$ ls
ls           lsattr       lsblk        lsb_release  lscpu        lsinitramfs  lsmod        lsof         lspci        lspgpot      lsusb
anne@alfa:~$ ls

  • At this moment your prompt shows ls. The lsattr command will display attributes of your working directory.
    Be aware this can be a very long list when your working directory is / ( root directory ).
    In this example is our home directory displayed.
    You must complete the ls command as followed.
    Type attr + enter.

anne@alfa:~$ ls
ls           lsattr       lsblk        lsb_release  lscpu        lsinitramfs  lsmod        lsof         lspci        lspgpot      lsusb
anne@alfa:~$ lsattr
————-e– ./Pictures
————-e– ./Downloads
————-e– ./Public
————-e– ./Desktop
————-e– ./Templates
————-e– ./Videos
————-e– ./Documents
————-e– ./Music
anne@alfa:~$

  • At this time after your first ls command executed your prompt is showed without ls. Now you need to type the whole command.
    If you want know how you disk looks like.
    Here you can see how many partitions you have. Notice the CD-Rom.
    Type lsblk + enter.

anne@alfa:~$ lsblk
NAME  MAJ : MIN RM     SIZE RO TYPE MOUNTPOINT
sr0         11:0     1         1024M  0 rom
sda          8:0      0             20G  0 disk
├─sda1   8:1     0          19.1G  0 part /
├─sda2   8:2     0                1K  0 part
└─sda5   8:5     0           880M  0 part [SWAP]
anne@alfa:~$

  • What kind of processor is installed in your computer.
    I you are interested about the properties, this command will show up technical information.
    Type lscpu + enter.

anne@alfa:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 30
Stepping:              5
CPU MHz:               1537.347
BogoMIPS:              3074.69
L1d cache:             32K
L1d cache:             32K
L2d cache:             6144K
NUMA node0 CPU(s):     0
anne@alfa:~$

  • I’m interested how many memory is used by the system.The default free command will display the information in KB format.
    If you want it in a human readable manner you must use the -h after your free command.
    Type free -h + enter.

anne@alfa:/$ free -h
total       used         free  shared    buffers     cached
Mem:              1.0G       776M      226M           0B         58M        424M
-/+ buffers/cache:       293M      709M
Swap:              879M          0B      879M
anne@alfa:/$

  • Last but not least the top command. System processes displayed in real time.
    Have you seen enough you can leave top by pressing q.
    (A imcomplete top page displayed)
    Type top + enter.

anne@alfa:/$ top

top – 19:16:30 up  4:36,  2 users,  load average: 0.01, 0.03, 0.05
Tasks: 125 total,   1 running, 124 sleeping,   0 stopped,   0 zombie
%Cpu(s):  8.4 us,  1.0 sy,  0.0 ni, 90.6 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   1027016 total,   808760 used,   218256 free,    60336 buffers
KiB Swap:   901116 total,        0 used,   901116 free,   440620 cached

  PID USER      PR  NI      VIRT     RES     SHR S     %CPU    %MEM      TIME+      COMMAND
2181 root        20   0      196m   65m    6092 S       2.3           6.5       1:29.23      Xorg
3253 anne      20    0     411m    24m     14m S      2.3            2.4       0:08.86      gnome-panel
3612 anne      20   0      306m    16m     10m S      1.0            1.7       0:15.53      gnome-terminal
3243 anne      20   0      366m    13m    9116 S       0.7           1.3       0:03.35      metacity
3127 anne      20   0      202m    10m    7768 S       0.3           1.0       0:00.64      x-session-manag
3282 anne      20   0      192m    9748   4428 S       0.3            0.9      0:00.23      tracker-store

  • Now we can do stuff what most people do, create, move, copy, delete folders and files.
    Now we’re able to advice many help functions in this magnificent system.
    As we’ve promised you to make a guide about move, create, change permissions etc…of directories and files.
    We’ll discuss this subject later on.
    We hope you enjoyed it and we’ll be back soon to guide us through the new chapter, management directories and files.
    Have a nice time -;)

Installing & Configuring HTTPD/Apache on CentOS 6.4

HTTPD/Apache is generally recognized as the world’s most popular Web server (HTTP server). Originally designed for Unix environments. The Apache Web server provides a full range of Web server features, including CGI, SSL, and virtual domains. Apache also supports plug-in modules for extensibility. Apache is free software, distributed by the Apache Software Foundation that promotes various free and open source advanced Web technologies.

This time we will divide this tutorial in two parts:

1. IP-based Virtual Hosts

a. One site per IP address

b.Host Header Names – multiple sites per IP address | port combination

2. Name-Based Virtual Hosts

a. NameVirtualHost 192.168.0.10 192.168.0.6

b. Then bind to each virtual host

So lets begin fir IP-Based Virtual Hosts

Apache by default, maintains 2 virtual hosts: TCP:80, TCP:443 determined by : /etc/httpd/conf/httpd.conf

So let’s begin by demonstration how to install and configure HTTPD/Apache

Pathfinder environment for HTTPD are :

“ /etc/httpd “ – this is primary config container

“ /etc/httpd/config/httpd.conf “ – this is primary config file under CentOS also RedHat.

yum install httpd

rpm –qa | grep –I httpd – this will enumerate package that have been installed and the man package is market with Red-X

1

When you install apache , you need to start from files that are located at httpd

Lets navigate to the file and see what we have there

cd /etc/httpd

ls –l  - here you will see the symlink of the httpd –Apache – the

run – directory simply contain a reference

logs – reference simple when you can find apache logs

2

enter command to see if the apache is running

ps –ef | grep –I httpd

pf –ef | grep httpd

service httpd status

Apache is not running yet

3

As mentioned before there are two directory for HTTPD-Apache

Conf – there are main configuration files

Conf.d – in Linux when ever you see .d suffix it means that is container of items that are included for larger configuration

Now  lets start HTTPD and see what will happen

Service httpd start

We have receive and error – this doesn’t mean that Apache is not running this is just DNS resolution problem but we will try to eliminate what kind of error we will receive , that is good for troubleshooting

4

let’s try to fix this:

vi /etc/sysconfig/network – change hostname to your hostname

5

vi /etc/hosts

6

Now type

Hostname yourhostname ( in my case is gnubizz.local) – as you see the error is gone

7

Now let’s continue where we left

netstat – ntl | grep 80 – you can see that the server has started

netstat –ntlp | grep 80 – the program is responsible is httpd

ps –aux | grep httpd – As you see primary apache process starts as root and subsequent processes run as apache(non-privileged users) and its defined on /etc/passwd

8

Now Apache is running lets tray to access the default page of Apache – open your browser and type either localhost or ip of your server

9

Let’s go a little bit deep , let’s change this default page and by default html file is stored on:

cd /var/www/html

vi index.html – close and check with browser

10

Note: Every changes that you made to HTTPD – Apache , issue reload and restart , and delete history and cookies for browser

Service httpd restart

or

!serv – this is a tip for shorts , Linux will remember last commands so than you can use ! and short names or by numbers  to restart the services or execute commands

An example of !

enter history command

ps –aux | grep httpd

11

!548

12

Now check with browser , you should have the same  page as it showing here

13a

Now we need to enable services for multi-user runlevels

chkconfig –list httpd – will show you the list

chkconfig httpd on  – this will enable runlevels

chkconfig –list httpd – do you see the difference

13

We need to check Apache logs, this is important when troubleshooting because apache traps messages between the client and servers and to see access and errors messages

cd /var/logs/httpd – this is default location

Check the access file first you can see how many time we have try to access our created website

watch tail access.log – main time refresh the browser and access again, do not close terminal you will see that again you changes in the terminal

My network has 254 available ip , so by  this l can assign to any pc or server within my house

So the CentOS that l am using has 192.168.0.4 gateway 192.168.0.1 255.255.255.0

First ip that l will assign to virtual interface will be 192.168.0.10 – l hope that is available :)

Ping 192.168.0.10 – l did not receive any replay this is good because l can see that this ip is available

ifconfig eth0:0 192.168.0.10

14

To have our website files in one place we need to create folders and give a name of our website

In my case l called my website site1.gnubizz.local ( your site you  can call as you wish )

mkdir /home/site1

mkdir /home/site1/www

cd /home/site1/www

vi index.html

15

Save and close

ls -l /home/site1 – to see who own the file , is owned by root , no need to owned by Apache , just read and write by apache that’s good

Capt

Now add a site1 and we need to be sure that Apache listens to 192.168.0.10:80

cd /etc/httpd/conf

vi site1.gnubizz.local.conf

16

save and close

Now navigate to :

vi /etc/httpd/conf/httpd.conf

As you can see here it’s already listen to port 80 , it tells here that it bind to all ip address

17

So we don’t want to bind to all ip addresses , we want to bind only to a specified ip address so that’s why we need to change

18

make symlink for site1

cd /etc/httpd/conf.d

ln –s ../conf site1.gnubizz.local.conf

service httpd restart

Note: incase you are facing problem accessing webpage you might check SElinux , pose problem when serving web content from: $HOME – so for temporary we need to disable

sestatus – check is Selinux is enabled

setenforce permissive

now point the browser with ip 192.168.0.10 – you should see this

19

So that’s it , you can add another site if you want just follow same steps ( site2, site3 )

cp site1.gnubizz.local.conf site2.gnubizz.local.conf

vi site2.gnubizz.local replace 1 with 2

cp -apvf /home/site1/www/index.html  /home/site2/www/index.html

ls -l /home/site2

modify vi /home/site2/www/index.html

than modify the /httpd.conf and add ip address ( 192.168.x.x )

cd /etc/httpd/conf.d

ln -s ../conf/site2.gnubizz.local.conf

browse new site called site2

So that’s it IP-Based Virtual Host

##########################################################################

Now lets begin with:

2. Name-Based Virtual Hosts

a. NameVirtualHost 192.168.0.10 192.168.0.6 – we have already configured

b. Then bind to each virtual host –  we have already configured

Add a second Virtual interface

20

We need to modify httpd.conf file

vi /etc/httpd/conf/httpd.conf – this time we will allow  to bind and listen in port 80

21

Save and close

Go to site1

vi /etc/httpd/conf.d/site1.gnubizz.local.conf – make the following changes

22

Save and close

Modify site2

vi /etc/httpd/conf.d/site2.gnubizz.local.conf

23

Save and close

Add this two virtual host to :

vi /etc/hosts

24

Check the status/names of virtualhosts

httpd –S – you can see that 192.168.0.10:80 is NameVirtualHost

Ca

Now try to access on browser by site name

Site1

25

Site2

26

Apache SSL | TLS with Self-Signet Certs – is ideal for intranet usage and default configuration includes self-signet certificates

yum install mod_ssl

yum install crypto-utils – check

we will generate a genkey for the host not for the website , l think is more appropriate for the defaults_:433   SSL site

type in terminal:

genkey gnubizz.local

click next

Capture

Select  2048 than Next – you have to wait sometime till the process finish

01-Capture

Click NO

02-Capture

We will not select this because every time any process that apache uses will require always  to be there and provide the password , it’s very secure of protecting your private key

03-Capture

Add information according your requirement

04-Capture

enter command to check who own the site1 directory

ls –l /home/site1

Capt

enter command to check site’s name and ssl.conf certificate

Ca

Make the changes on:

vi /etc/httpd/conf.d/ssl.conf

05

Now open the browser and check – you should have similar as shows in the pic

Select “ l Understand the Risks

06

Click on view

07

certificate has been issued

08

Note: The real key for this tutorial is  that you can issue your own self-cert or generate request via CA

So this is all , see you next time :)

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.

Follow

Get every new post delivered to your Inbox.