unix

what is unix/linux internals ?

When somebody asks me about how strong you are in unix/linux internals ? What do they really mean ? Though i have some idea, i would like to hear from some experts that, what is really meant by unix/linux internals. My ideas are, i have to be strong in, linux boot process user creation how does a command executes filesystem related ...

bash problem with grep

Whenever i write grep -v "0" in order to ignore the 0 number somehow the number 10 is getting ignored as well. Please help me use the grep -v "0" with ignoring 0 in the process and not ignoring 10 ...

Is there a way to have a string as a switch using getopts?

I am seeing if there is a way for getopts to handle switches with strings instead of characters. For example, I would like to supply something like this: script.ksh -file1 file1.txt -file2.txt Instead of: script.ksh -f file1.txt -g file2.txt Is this possible with unix getopts? Thanks! ...

Set environment variables in C

Hi, Is there anyway to set environment variables in linux using C? I tried setenv() and putenv(), but they don't seem to be working for me. Thanks in advance. ...

Real-world programming examples of the Unix philosophy

What are some specific[1] real-world code[2]/design examples, personal anecdotes, mistakes learned (with more emphasis on personal anecdotes, mistakes learned instead of pointing out third-party software) that best illustrate the programming philosophy of Unix? For a start, here's Raymond's summarization of the philosophy from The Art of...

Is strftime with nanoseconds possible in bash?

Is there any way to obtain Unix Time with nanoseconds with strftime in bash? My line for unix time : <command> | awk '{ print strftime("%s"), $0; }' I cannot use date +%N because date is only evaluated once. Is there any work around? ...

sometimes my file just freezes in my vi |vim, what happened?

Sometimes when I edit my file using vi or vim, my file just freezes. Even if I type Ctrl+C or Ctrl+D, it still freezes there. I kill -9 <pid> from another terminal, the pid is killed, but the file still freezes there. I guess I must have typed some combination of key which I do not know. Does anybody have an idea? ...

Removing Parts of String That Contain Digit With Sed/Perl (one-liner)

I have a data that looks like this: AB208804_1 446 576 AB208804_1orf 0 AB208804_20 446 576 AB208804_20orf 0 I want to convert them into this: AB208804 446 576 AB208804orf 0 AB208804 446 576 AB208804orf 0 just by removing _\digit part in column 1 and 4. Why this line doesn't work: sed 's/_\d+//g' What's the correct way to do it...

write(2) still reports success even though I have closed the socket

I have encountered a problem where even after my server side close()-ed the socket, the client side still can do a single write(), only the second write() will return SIGPIPE, this causes me to loose data as I do not have application level handshake and solely relying on the return value of write(). Is there a way for me to get SIGPIPE s...

alias in a script

In linux, if I put a command in a script that contains an alias, I see that it doesn't get expanded. How can I fix that? I am using bash. ...

specifying file descriptor number?

My understanding was that one could not control the file descriptor (integer) assigned by the OS when opening a new file using open(). How then is it possible in a bash shell to assign a specific file descriptor using a command like exec 5>&1 (I suppose I could find out by reading the bash sources...) ...

Locating most recently updated file recursively in UNIX

For a website I'm working on I want to be able to automatically update the "This page was last modified:" section in the footer as I'm doing my nightly git commit. Essentially I plan on writing a shell script to run at midnight each night which will do all of my general server maintenance. Most of these tasks I already know how to automa...

can a process create extra shell-redirectable file descriptors?

Can a process 'foo' write to file descriptor 3, for example, in such a way that inside a bash shell one can do foo 1>f1 2>f2 3>f3 and if so how would you write it (in C)? ...

What's the easiest way to acquire a lock on a shared variable for a UNIX C program?

I am writing a C UNIX program that is threaded and shares one variable across all threads. What would be the easiest way to acquire a lock on this variable? I can't find any small libraries just for locking in UNIX. Any suggestions how to do this? Thanks, Boda Cydo. ...

How can I supress filename extensions at the command line interpreter and batch files?

Example: I have a file: FILENAME.EXT and would like to extract FILENAME without the .EXT I want to be able to use the extensionless filename for a command which only accepts filenames without its extensions. I have a utility called BCHECK which accepts as its argument a filename with no extensions. Using BCHECK *. does not work because a...

Finding security problems in a given code

Hello guys, Can some one please tell me an approach for finding security flaws in a given code. For ex: in a given socket program. Any good examples or good book recommendations are welcome. Thanks & Regards, Mousey ...

Can I set noatime for my XEN guest OS partition? Will it work?

I have a VPS in cloud environment based on XEN Virtualization platform. /etc/fstab looks like that: LABEL=PRGMRDISK1 / ext3 errors=remount-ro 0 0 As far as I know IO can pretty easily become a bottleneck if some other VPS neighbor will use it intensively(IO bandwidth is a shared resource for multiple guest VPS). ...

Adding number infront of the FAX number

I want to send the fax to the user using hylafax sendfax command. But the user will type only fax number. But I need to add three digit number infront of the fax number. How to add the three digits in front of the fax number. ...

simple shell using execlp goes weirdly

I am reading GNU/Linux application programming the 2nd edition,you can reach what am reading from here.After I write the code similar to his,but it work strangely: $ ./shell ./shell>>quit $ ./shell ./shell>>date Sun Aug 8 21:19:37 CST 2010 ./shell>>quit $ ./shell ./shell>>abc execlp failed: No such file or directory ./shell>>quit ./she...

C# System.PlatformID.Unix vs. Linux

Question: I need to make some system calls in my C# applications. Unfortunately, this behaves differently on Linux than on UNIX. Now I used to switch the Operating system at runtime like this If Environment.OSVersion.Platform = System.PlatformID.Unix Then ' Linux/Unix ' ElseIf Environment.OSVersion.Platform = System.PlatformID.Mac...