Skip to content

Tag: bash

Why does SetSUID not work for shell script?

I am trying to create a executor program for regular users on linux with SUID bit set so whatever commands, passed to the program as parameters, get executed with root permission. However when I try to implement this as a bash script, this does not work, where it works when implemented in C. I want to know wh…

How to read a file line by line

I try to read a file line by line. File to read: Script: When I execute the script, this window will be opened: (Notice how some values are repeated, and the contents don’t correctly alternate between names and versions): I’d like to create an array with all package names and versions. Answer You …

SSH – Entering a Passphrase Only Once

On $ ssh localhost, I was being asked to provide password. It was tedious and kind of annoying to provide password for every login. So, I have created ssh keys with passphrase.. I have copied the content of the ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys Now, on $ ssh localhost I was being asked to provide pa…

bash: Possible to require double Ctrl-c to to exit a script?

End-goal: BASH script that is waiting for background jobs to finish does not abort on first Ctrl-c; instead, it requires a second Ctrl-c to quit. I’m well aware of how the BASH-builtin trap works. You can either: Use it to ignore a signal altogether (e.g., trap ” 2) … or Use it to have arbit…

How can I make a hybrid bash/tcsh script on Linux?

I have one script which runs in Bash and and other which runs in tcsh. I need to run them both from the same script. How can I create a script that can run both bash and tcsh commands? Answer Most shells have an argument which allow you to pass them a string to run as a command, for example,

ImageMagick using convert and rename output

I a directory I have several files name like 13992.jpg 13993.jpg 13994.jpg 13995.jpg … How do I rename these files using convert? I have tried but it is not working… Any suggestions? Answer you probably want to run convert in a loop, like consider also this little “trick” for renaming:

Check if a condition is false

It is seems to be an easy question, I wonder why googling didn’t give anything helpful — nor in StackOverflow, nor in tutorials. I just need to check using bash that a condition is false. Of what I found I tried and none of them print Hello. I found only two similar questions, but the end answer i…