Techpulp
  • Register
  •   | Log in   

  • Articles
  • Questions
  • TechNews

How to change priority of a process with renice

Dec 6th

Posted by Neo in [...]

No comments

Unlike “nice” command, the “renice” command expects PID of a process and can be used to alter priority of an already running process. It can take multiple PIDs at a time to alter scheduling priority. However to increase priority of a process, one should have root privileges while reducing the priority can be done by any user. This all applies for the processes owned by self. The following example reduces scheduling priority (sets 10 as priority) of a background process with PID 987.

[neo@techpulp ~]# renice +10 -p 987

To alter scheduling priority of all processes owned by a specific user, the More >

Change scheduling priority of all processes owned by a, renice command, Unix Commands

Run a command with low/high priority in Linux

Dec 6th

Posted by Neo in [...]

No comments

The “nice” command can be used to alter the priority of a command executed. This commands takes an optional argument with -n option that specific niceness of process going to be created. This option expects an integer ranging from -20 (highest priority) to 19 (lowest priority). This is an optional parameter and its default value is 10. The following example shows how a new software installation using “yum” is set to low priority.

[neo@techpulp ~]# nice yum install Basket

In general a process created in Linux has nice value of 0. So you can use “nice” command to specify lower value to specify More >

Change the priority of a process/command in Linux, How to specify priority of a process to the kernel proc, Run my command with low priority in Linux, The nice command

How to find where my command is stored in Linux

Dec 6th

Posted by Neo in [...]

No comments

The “which” command lets you know exactly which program is run when you type a command at shell prompt. There is an environment variable called PATH which contains list of directories which will be looked up for the executable when a command is attempted to run at command line. The following example shows how the “which” command is used to find the path of “find” executable.

[neo@techpulp ~]# which find
/usr/bin/find
[neo@techpulp ~]#
The whih command, Unix Commands, Where is my command in Linux

How to create PDF file from a man page in Linux

Dec 6th

Posted by Neo in Desktop

No comments

The ps2pdf command can be used to create PDF in Linux. This command converts PostScript to PDF using ghostscript. You can redirect the output of “man” command to ps2pdf command to geneate PDF out of man page. The following example shows how to create a PDF of ifconfig man page.

[neo@techpulp ~]# man -t ifconfig | ps2pdf - > ifconfig.pdf
[neo@techpulp ~]# okular ifconfig.pdf &
[neo@techpulp ~]#
Create PDF using Linux command line utilities, okular - The PDF viewer with review support, Usage of ps2pdf command

How to configure Proxy settings in Firefox Browser

Dec 5th

Posted by Neo in Firefox

1 comment

Open Firefox browser and open preferences window by selecting the menu as shown below. Press “Edit” in the menu bar and then press “Preferences” item in the menu.

This opens up Firefox’s preferences window. In that select “Network” tab under “Advanced” section as shown below.

Then press the “Settings” button to open “Connection Settings” window as shown in the below diagram.

If you have proxy server IP address and port number, just select “Manual proxy configuration” option and enter them in HTTP proxy and port text fields respectively. If you use exactly same proxy for all connections like HTTPS, FTP etc then select More >

Firefox Browser, HTTP/HTTPS/FTP proxy settings in Firefox

How to get exit code of previous command in Bash

Dec 5th

Posted by Neo in Bash

No comments

The special variable “$?” returns the exit code of last executed command in Bash shell script. The following example gets the exit code of “grep” command whose exit code will be zero if finds match and 1 otherwise.

#!/bin/bash
grep neo users.txt
if [ "$?" == "0" ]; then
   echo User neo detected
else
   echo User neo not found
fi
Bash Shell Scripting, Exit status of last command in Bash, How to detect exit code of last command, What is the exit code of last command

Why my application can’t open more than 1024 or 4096 sockets in Linux

Dec 5th

Posted by Neo in C/C++

No comments

Typically socket “open” call doesn’t fail unless you have missed out closing the previous connections using “close” system call. Typically Linux/Unix sets a maximum limit for the number of open FDs. That means you can’t keep FDs in open state more than certain number. These settings can’t be changed as a normal user of the system.

These limits can be seen using “ulimit -a” command.

[neo@techpulp ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31729
max locked memory       (kbytes, -l) 32
max memory More >
How to resolve socket open error, ulimit command

Bash shell script to convert string from lower to upper case and vice versa

Dec 5th

Posted by Neo in Bash

4 comments

The “tr” command can be used to convert a string variable to upper or lower case. The following function in a bash script converts first argument to lower case.

Convert the given argument into an all lower case string.

toLower() {
echo $1 | tr "[:upper:]" "[:lower:]"
}

GENDER=MALE
GENDER=`toLower $GENDER`
echo $GENDER

Convert the given argument into an all upper case string.

toUpper() {
echo $1 | tr  "[:lower:]" "[:upper:]"
}

GENDER=male
GENDER=`toUpper $GENDER`
echo $GENDER
Bash function to convert argument to lower/upper case, Bash Shell Scripting, Change upper/lower case in Bash script, Unix Shell Scripting

Why GNU Make always says `target’ is up to date

Dec 5th

Posted by Neo in GNU Make

No comments

The GNU make expects the rule target to be files by default. That’s why it first checks the presense of a file/directory with the name specified in the rule. For example GNU make attempts to find if a file with name “target1″ with the following Makefile.

target1: prog
prog: one.o two.o
	gcc $^ -o prog

If by chance you have a file or directory with name “target1” in the same directory, GNU Make interprets its last modified date. Because of that some times Make doesn’t compile anything saying target is up to date even if some of the dependencies are changed.

It is More >

How to resolve target is up to date error in GNU Makefi, What is the meaning of .PHONY in GNU Makefile, Why GNU Make doesn't compile at all

GNU Make – How to compile all c files in present directory

Dec 5th

Posted by Neo in GNU Make

1 comment

The “shell” built-in function supported by GNU Make can be used to get the list of C source files in a directory. Then a list of corresponding object files can be created by replacing the file extension in the file list. The following example shows how to compile all C source files present in the current directory to generate an executable named “target“. If you are doing copy and paste of the following example, ensure that you place TAB for all commands under each rule. Otherwise GNU Make complains about “missing separator” error.

TARGET=target
SRCS=$(shell ls *.c)
OBJS=$(SRCS:.c=.o)

all: $(TARGET)

$(TARGET):$(OBJS) More >
GNU Makefile example to compile all C files, How to resolve missing separator error. in GNU Makefile
« First...10«1819202122»...Last »
  • Categories

    • Linux
    • Bash
    • Command Line
    • C/C++
    • Networking
    • Administration
    • Fedora
    • HTML

Recent Articles

  • How to enable/disable/start/stop a service in Fedora 16
  • How to switch between threads in GDB
  • How to improve performance of Linux application
  • How to find size of code and data segments of a program
  • How to catch signals in a bash script

Recent Comments

  • Svetlana on How to access command line arguments in a bash script
  • Sergey on How to mount file system using SSH in Linux
  • Mufliah on How to open a new window on click of a button in Java Script
  • 6kgxiRC on Show files by size in ls command
  • Gildas on How to disable directory listing by Apache web server

Copyright © 2007-2011 Techpulp
Login

Lost your password?

Reset Password

Log in