Skip to content

Tag: linux

C code with ncurses compiled with libtinfo dependency

I’ve recently written a minesweeper implementation in C using ncurses on linux; everything works fine on my pc, but if I try to give the compiled binaries to someone else they often get the error: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or direct…

how to make SSH command execution to timeout

I have a program like this: In the above code, I am trying to SSH to the remote server, and tries to check if I can connect or not. I have few servers, which is password less is activated and few servers for which passwords are still not yet deactivated. So my concern, if there is a password, it will

search for files not accessed for x days

How can I find files in Linux that were not accessed for X days? I found that command, but it will show files that were viewed for the last x days: Answer Use -atime +60 to see files that have not been accessed within the last 60 days:

How to capture all the commands typed in Unix/Linux by any user?

I would like to capture all the commands typed in Unix/Linux by any user. There are few alternatives like using script command or acct utility. But the problem with them is they dumb everything from the terminal to a file or just provide the summary of the commands. I am looking for a utility where it will pr…

Sending signal to pthread to abort sleeping

I’m have a pthread function, which sleeps most of the time using usleep() I would like to send a signal from the main process to the thread to interrupt the sleeping sometimes. The problem is that I can’t find any reference of which signal exactly to send using pthread_kill() the usleep() man page…

Tracking a program’s progress reading through a file?

Is there a way to figure out where in a file a program is reading from? It seems like might be doable with strace or dtrace? To clarify the question and give motivation, say I have a 10GB log file and am counting the number of unique lines: $ cat log.txt | sort | uniq | wc -l Can I

Display duplicate lines in two different files

I have two files and I would like to display the duplicate line. I tried this but it doesn’t work : cat id1.txt | while read id; do grep “$id” id2.txt; done I am wondering if there are any other way to display the duplicate lines in the file. Both of my 2 files contain list of ids. Thank you…