unix

How can I kill all shells in Unix at once?

My Mac becomes slow over time. The reason is the huge amount of my shells, such as Bashes and Fishes. Each shell has different PID. Killing shells one by one is too cumbersome. How can I kill them at once? ...

What is a signal in Unix?

This comment confuses me: "kill -l generally lists all signals". I thought that a signal means a quantized amount of energy. [Added] Please, clarify the (computational) signal in Unix and the physical signal. Are they totally different concepts? [Added] Are there major differences between paradigms? Is the meaning the same in languages...

Is it possible to add multiple commands to the readline .inputrc file?

I'm trying to configure my Terminal and I would like to insert @{} at one key-stroke. This works with the following code # .inputrc "\e\"": "@{}" But I also want the cursor to end up inside the braces. How can I do this? The following doesn't work. # .inputrc "\e\"": "@{}": backward-char ...

Explicitly close file handles or let the OS close them in Unix C programming?

In Unix C programming, is it considered good practice to explicitly close file handles before the process exits, or is it instead good practice to let the OS close the file handles and thus avoid unnecessary code? Which of the two would generally be considered as the preferred alternative? Example: int main (int argc, char* argv[]) { ...

What characters should be restricted from a Unix file name?

Consider a Save As dialog with a free text entry where the user enters a file name as free text, then clicks a Save button. The software then validates the file name, and saves the file if the name is valid. On a Unix file system, what rules should be applied in the validation such that: The name will not be difficult to manipulate l...

select on UDP socket doesn't end when socket is closed - what am I doing wrong?

I'm working on Linux system (Ubuntu 7.04 server with a 2.6.20 kernel). I've got a program that has a thread (thread1) waiting on a select for a UDP socket to become readable. I'm using the select (with my socket as the single readfd and the single exceptfd) instead of just calling recvfrom because I want a timeout. From another threa...

Subversion: unix permissions on disk for secure apache access

I moved a Subversion repository from a Windows box to a UNIX machine. In both environments I've handled authentication through Apache. On the UNIX box after the move, I could checkout source but received the following error when committing anything: svn: Can't open file '/home/brianly/svn/test/db/txn-current-lock': Permission denied ...

How do I determine if a directory is an NFS mount point in shellscript

I want to write a sh/bash script that can determine whether a particular directory is a mount point for an NFS filesystem. eg something like $ mkdir localdir $ mkdir remotedir $ mount host:/share ./remotedir $ classify_dirs.sh --> localdir is local --> remotedir is an NFS mount point ...

Detecting that log file has been deleted or truncated on POSIX systems?

Suppose a long-running process writes to a log file. Suppose that log file is kept open indefinitely. Suppose that a careless system administrator deletes that log file. Can the program detect that this has happened? Is it safe to assume that fstat() will report a link count of zero for a deleted file? Truncation, it seems to me, is...

stdout thread-safe in C on Linux?

Is writing to stdout using printf thread-safe on Linux? What about using the lower-level write command? ...

fiding the used and free disk space in percentage by using unix

How to find the free disk space and used disk space in percentage by using unix? I want that in percentage only. ...

maildir headers problem

Hello, I have the followign bash script to update mtimes for maildir files: #!/bin/bash for i in /test/emailfile do date=$(sed -n '/Received: from/ { :a; n; /;/ {s/.*; //p;q}; b a }' "$i") newdate=$(date -d "$date" +'%Y%m%d%H%M.%S') touch -t "$newdate" "$i" done This script has always worked fine, with standard headers ...

How do I use Perl on the command line to search the output of other programs?

As I understand (Perl is new to me) Perl can be used to script against a Unix command line. What I want to do is run (hardcoded) command line calls, and search the output of these calls for RegEx matches. Is there a way to do this simply in Perl? How? EDIT: Sequence here is: -Call another program. -Run a regex against its output. ...

How do I make cron run something every "N"th minute, where n % 5 == 1?

I know that I can have something run every five minutes in cron with a line like: */5 * * * * /my/script What if I don't want it running at 12:00, 12:05, 12:10, but rather at 12:01, 12:06, 12:11, etc? I guess I can do this: 1,6,11,16,21,26,31,36,41,46,51,56 * * * * /my/script ...but that's ugly. Is there a more elegant way to do ...

Java and unix

I want to delete the old log files in log directory. To delete the log files which are more than 6 months, I have written the script like find /dnbusr1/ghmil/BDELogs/import -type f -mtime +120 -exec rm -f {} \; By using this script i can able to delete the old files. But how to invoke this script by using java? please any one help me....

changing maildir order

I recently asked this question and worked out that the reason a single email message is displaying out of order is not in fact because of the date, but because of the order of the messages. I would like to modify my script to make sure all messages are in the correct order, but am unsure how to do this. Is it just based on the order in w...

How do I create a unix password hash with php

I'm trying to create system users with a php script securely, In that, I'd like to be able to hash the password with the php script, so that their password shows up nowhere in the bash history. How to I take a string, and hash it so it is a unix password hash? $UX_PW = some_function('my_password'); exec("useradd -p $UX_PW newusername")...

Is there an alternative to MKS Yacc that supports "selection preference syntax" or something very similar?

MKS Yacc supports a notation which their web site calls "selection preference syntax". It isn't illustrated, but it consists of a token in square brackets, optionally with a caret, and it indicates that a particular token is required to follow, or is required not to follow, the rest of the rules: non_terminal: TOKEN1 non_terminal2 TOK...

mdfind equivalent on linux?

ok, so I finally got a Macbook pro and to tell the truth I am astonished by both the architecture, speed, and os on this laptop. Mac OS X is a beautiful system, from the mach kernel up to finder and spotlight and speaking of spotlight, it truly blew me away when I just needed to execute this command to get all unix executables and ONLY ...

How to test if a given path is a mount point

Suppose do you want test if /mnt/disk is a mount point in a shell script. How do you do this? ...