Showing posts with label commands. Show all posts
Showing posts with label commands. Show all posts

Thursday, February 14, 2013

AppArmor in Ubuntu

AppArmor is the most important security feature in Ubuntu which has been included since Ubuntu 7.10. We are not aware of this security feature because it’s a background process. As it is runs in the background silently we couldn’t identify what it is and what it’s doing.
AppArmor:-
AppArmor locks down vulnerable processes and restrict the damage that vulnerable process can cause thus providing a good security. AppArmor is similar to SELinux which is included by default in Fedora and RedHat. Both provide “mandatory access control” security. But AppArmor also allows Ubuntu’s developers to restrict the actions, processes can take.
For example, one application that is restricted in Ubuntu’s default configuration is the Evince PDF viewer. When Evince runs as a user account, it can only take specific actions. Evince only has the permission to run the PDF documents. If Evince discovered and opened a malicious document, AppArmor would protect the damage that Evince could do. So AppArmor gives the particular actions to be run by the applications or the process that user can access for restricting the exploitation of the software.
Viewing AppArmor’s Status:-
 We can view the AppArmor’s status by running the following command:
           sudo apparmor_status

We can see the AppArmor profiles that are installed, the confined and enforced process that are running.
AppArmor Profiles:-
In AppArmor, the restriction put in the processes are done by the profiles. We can see the list in the AppArmor status, the profiles that are installed on the system which comes with Ubuntu. You can also install other profiles by installing the apparmor-profiles package. You also can create your own AppArmor profiles to restrict the software.
As we saw in the status, that profiles run in the “complain mode” or “enforce mode”. In enforce mode, the default setting for the profiles that come with the Ubuntu - AppArmor prevents the applications from taking restricted actions. In complain mode it does the same and also it creates a log entry complaining about this. Complain mode is ideal for testing the AppArmor before enabling it in enforce mode so that we can see the error’s that would occur in the enforce mode.
Profiles are stored in the /etc/apparmor.d directory. These profiles are plain-text files that can contain comments.
You can also lock down the Mozilla FireFox for the increased security, but it doesn’t do this by default. The /etc/apparmor.d/disable folder contains a link that shows it’s disabled. You can see the Firefox profile i.e. usr.bin.firefox in the /etc/apparmor.d directory.
To enable it and confine Firefox profile with AppArmor, run the following commands:
        sudo rm /etc/apparmor.d/disable/usr.bin.firefox
        cat /etc/apparmor.d/usr.bin.firefox | sudo apparmor_parser –a
After you run these commands, run the sudo apparmor_status command again, and now we will see that the Firefox profiles are also added.
We can also disable this Firefox profile, run the following commands:
       sudo ls -s /etc/apparmor.d/ usr.bin.firefox /etc/apparmor.d/disable/
       sudo apparmor_parser –R /etc/apparmor.d/ usr.bin.firefox

Saturday, February 9, 2013

Basic of Shell Programming

Why shell?
Even though there are various graphical interfaces available for Linux, the shell still is a very neat tool. The shell is not just a collection of commands but really good programming language. You can automate a lot of tasks with it. The shell is very good for system administrator tasks. You can quickly try out if your idea which makes it very useful for simple prototyping and it is very useful for small utilities that perform some relatively simple tasks where efficiency is less important than ease of configuration, maintenance and portability.
Let's see how it works:
Creating a script file:-
There are two ways to create a script file, i.e. we can save script file with .sh extension that will indicate that it's a shell file or we can write “#!/bin/sh” at the very first line. The “#!” character tells the system that the first argument that follows on the line is the program to be used to execute this file. In this case “/bin/sh” is shell we use. And for creating script file we can used any text editor like GEDIT, VI editor etc.
Variables:-
As we know every programming language needs variables, without variables it’s next to impossible to do programs. But in shell programming we don't have data types. All variables are of string data types and we don't need to declare it, to assign values to variables. Syntax is as follows:-
Variable_name=value
Even we don't need terminator operator to end statement, actually its optional, you can used it if you want.
Examples:-
str=”This is shell Programming ”
num=169
You can also print the values of variables by just using “$” symbol in front of variables.
echo “values of num is=$num”
It will print value of num that is 169 on the screen.
Comments:-
In Shell programming we can use comments for user understanding using # symbol at first of your statements.
Example:-
#This is my first shell program.
#Program based on Linux.
Reading values from Keyboard:-
This is very important to take values from user, as I mention above shell programming doesn't have data type so we don't need to specify which type of values we need to read. To read values from keyboard just use “read” command as given below:-
echo "Enter value for A"
read A
echo "Enter value for B"
read B
C=`expr $A + $B` - Line5
echo "Addtion is =$C"
Now, here some more things come at Line5 that is back quotes and expression (expr). To do any kind of calculation we have to follow this procedure.
In shell programming we have many things to do, but above things are the basic which we have to know at the initial stage of shell programming. For more information you can search it on www.google.com or you can also mail me on panditdilipr@gmail.com .

Tuesday, February 5, 2013

Understanding basic shell commands of Linux



Understanding basic shell commands of Linux:-

Shell:-
The shell act's as the most powerful interaction between user and the kernel in system. The shell is a command line interpreter, it interprets the user typed commands in console of terminal.
There are various types of shells are available, which are as follows:
•       Bourne shell
•       C shell
•       Korn shell
•       Bash shell
Let's discuss some basic shell commands:-
pwd:
The shell command “pwd” prints the current working directory. That means if you are working in home it will display “/home”.
Ex:ravi@ravi:~$ pwd
/home/ravi
cd:
The shell command “cd” allows us to change the directory. We have to move to particular directory to access the contents in it or by specifying explicit  path of a file, so we can access any file.
Ex:
ravi@ravi:~$ cd Downloads
ravi@ravi:~/Downloads$
cat:
The shell command “cat” displays the contents of file in console.
Ex:
ravi@ravi:~$ cat workshop
Displays the contents of file workshop
rm:
The shell command “rm” allows us to remove the file from current directory.          
Ex:
ravi@ravi:~$ rm unixfile
After executing this command the file “unixfile” is removed or deleted.
rmdir:
The shell command “rmdir” allows us to remove the directory from current directory.
Ex:
ravi@ravi:~$ rmdir directory
After executing this command the directory named “directory” is removed from current directory.
touch:
The shell command “touch” allows us to create file in current directory.
Ex:
ravi@ravi:~$ touch newfile
After executing this command the file “newfile” is created in current directory.
mkdir:
The shell command “mkdir” allows us to create directory in current directory.
Ex:
ravi@ravi:~$ mkdir newdir
After executing this command the directory newdir.
nautilus:
The shell command “nautilus”  allows us to show the home window.
Ex:
ravi@ravi:~$ nautilus
ps:
The shell command “ps” allows us to show the current running process started by the user.
Ex:
ravi@ravi:~$ ps
PID TTY          TIME CMD
3795 pts/0    00:00:00 bash
4867 pts/0    00:00:00 ps
top:
The shell command “top” allows us to show the all the daemon process.
Ex:
ravi@ravi:~$ top
ls:
The shell command “ls” allows us to show the contents of current directory.
Ex:ravi@ravi:~$ ls

Friday, February 1, 2013

CREATE AND RUN YOUR OWN COMMAND ON LINUX

Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. The script can be run only after file permissions have been changed to executable mode. Once changed, copy it to the binary path of Linux so that it can be run just like system-defined commands of operating systems. Sometimes we need multiple commands to fulfill our desire task but it’s not flexible for user to execute all bunches of commands every time, so we can combine them together   and after that we can form our own command. Follow these easy steps to create a command in Linux.

Step 1:- First step to create bash file which will run your command on command line. Open GEDIT, and type following code on file,

   #!/bin/bash         
   echo "this is my first chance to create my own command'"     
   #then the rest of the files     
   echo "files of current directory are"
   ls

Give the file name as same as Command name you want to create, save this file.

Step2:- Now, you have to make this file executable. To make it executable use chmod command with option +x. CHMOD command is basically used to give access permission of files to user accounts. For more information about chmod command, open your terminal and type man chmod, you will get all information about chmod.
(Example for making file executable)

    chmod +x filelist  ( filelist is name of file )

Step3:- Now you have to copy this executable file to binary path of Linux that is “/usr/bin/”.

Sometimes for sudo (super user do) account user, it will not give you permission to copy this file to binary path of Linux. So to solve this we have to switch our account to root account, for this just type su command on terminal, it will asked you the current account password (only if you don’t created root account else you have to give root account password). After switching to root account copy your file into binary path that is “/usr/bin/”.

Now, try to execute your command, you can modify bash scripting file as per your requirement but you should have some basic knowledge of shell scripting to make perfect command that you want to create.

Friday, December 7, 2012

Automatic Voice Command Execution


Hello Readers, this is a new concept that I am going to explain you in this post. Before starting main topic I will like to clear basic concepts, because if you don’t know the basic concept then you will not understand this concept properly. And according to my knowledge still this concept is not developed, and this is only concept that I thought and if you want, you can develop it.
Now back to the basic concepts, you should know voice frequency, how to convert voice frequency into text, and programming on any Linux Operating System, and the most import Multithreading, Because if you don’t know multithreading then you can’t develop it.
As we know voice is nothing but the frequency and we can easily convert analog frequency (sin wave) into digital frequency (square wave) by using some methods and once it converted into digital frequency, we can easily convert it into text.
Fig : Automatic Voice Command Execution
Step 1 is completed, now in next step we have to check a file where all the commands are stored but it is a hard task to recognize actual command because the voice frequency which was converted into text that may be converted into wrong formats or may be spelling of commands converted in wrong way. But this problem will solve by proper converting, for this we have to check (debug) all possible conditions.
Now in 3rd and final step we have to read all commands one by one and simply execute them on terminal of Linux Operating System that you are using for operations. The last step is seen to very easy but it not, because we have to execute all commands one by one that is easy but when to execute or when to wait (if file is empty) that is so much difficult but there is a solution that is multithreading. For more information of multithreading you can refer to any book or you can search it on http://www.google.com. To execute all commands we require two or more threads, its totally depends on Programmers logic.
I am hoping that all readers will like this concept and if anyone wants any kind of help to develop this concept then you can mail me on panditdilipr@gmail.com.