Showing posts with label process. Show all posts
Showing posts with label process. Show all posts

Wednesday, September 3, 2014

Greenify Your Android.

Many of the Android phone users have the problem of battery life not lasting over about 6 hours of the day. The main culprit behind this problem is a lot of processes running in the background. Many of you would have observed that as you install more and more applications on your device, the phone becomes slow and battery life becomes very less. This is because nearly each application that you install has a background service that keeps running continuously on your device. Developer Oasis Feng has come out with a solution for this problem.

Saturday, March 22, 2014

GETTING PROCESS INFORMATION


We all knows that in Linux operating system whatever we execute is a process. So many time we don't know how to get proper information about which process. Basically it's depend on our need that why we have to get information of process.Now if we consodering a normal system user, then we can consider that he needs atleast process id to do some basic operations on that process. For example I open a firefox browser and i want to know what it's process id, so there are two way to get process id.

Monday, September 9, 2013

How Linux stores Process Information


In Linux,whenever you run anything it runs as a process in Linux Operating System, so all of details are store in system, and it's very simple to get those information from this system. The point is to be consider here is how system store that information and where?. For example if you run C program and after that you have a.out object file that is generated by default in current directory. Okay after executing that a.out file, it also runs as process in system, for verification you can check it on terminal by using top command, top command will show you all information regarding a.out file, top will show process id, user name priority etc., as shown in figure.

Fig:-1

The next thing is how system maintain information of any process that in execution, after creation of process in Linux, System will create a directory of process with it's P_ID name. To check it, type ls /proc command on terminal, you can see that a directory is created with process_id of a.out in below figure. That directory has all information of a.out process. Here pgrep command is use to check the process id of a.out process.

Fig:-2

Now you can get all information of process(i.e. a.out process) from that directory which has same name as process id of process a.out. A directory 6114 has following files in it, it may happend that some of files may be missing.
Fig:-3

To check status of a.out process type cat /proc/PID/status. It will show all status information of a.out process as shown in figure.
Fig:-4

You can also check the maping information of your process by typing cat /proc/PID/smaps
Fig:-5

In this blog a just give a small example of how to get process information, you can do lots of thing with /proc directory.

Saturday, September 7, 2013

top and htop shell command


Every one knows that Process means program in execution and in Linux everything is works by processes. So it's important to have good knowledge of Process Management/Process Handling. Here Process Management doesn't means that we learned during our academic years in subject called Operating System or Advance Operating System, it means, simply working on process or handling it on Terminal/GNOME-Terminal.
I am writing this blog for those Mind-Hunter's who are crazy to work on Linux Terminal. See, it's simply impossible to know everything in Linux, because Linux has 1000's of Distro for different purpose but still we are crazy to learn new things and that is good.
Now back to main topic, we know that if any one wants to know about process details during execution of Process or simply when Process is running, we always suggest or use top command in terminal. Thats shows following output on terminal.

Fig:- Output of top

In above fig, we can see all processes are running but you can also check a particular process information by using top with it's option -p . But again we have to use top command and have to check for the process ID, instead of doing this you can use pgrep command to know the process ID. Normaly pgrep is use to find the process ID of any process, for this you just have to follow following command.

pgrep 'process name'

Fig:- Output of pgrep

Now to check information of single process using top command follow this command,

top -p 'process_id'

Fig:- Output of top for single process


There are many other options are also available you can try them also. To check documentation of top command typr man top on Gnome-terminal.

Top is a great command to work with runtime processes but I will suggest to use htop command. htop is almost same as top command but htop have some advance facilities for us. htop show cpu, memory and swap usage in better way.

Fig:-Output of htop

You can also modify the look of htop by using it's setup option. To do so type shift+c and you will move to setup , as per your need you can make changes in htop and to exit setup press Esc button. htop have more powerful option you can also try them. To see documentation of htop type man htop. It also have some short cut options that shown below when you use htop(i.e. Function keys).
Fig:- Setup of htop

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