Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

2
votes
2answers
593 views

How to take control back on a separate process in Linux shell?

I just set up a Minecraft server on my VPS for my brother and I ran it with a bash script : sh ./server.sh& This way, the server is running and I can still work on the same command line with ...
-1
votes
2answers
432 views

Allow non-root users to execute specific command

As in title - I'd like to allow non-root users to execute specific command, but not binary. Eg: # killall sshd but not allow to kill any process.
4
votes
3answers
2k views

How can I start new window in the same screen session automatically?

I read How can I start multiple screen sessions automatically?, but I don't understand the first accepted reply: screen -dmS "$SESSION_NAME" "$COMMAND" "$ARGUMENTS" In my case I need to ...
10
votes
3answers
14k views

How can I start multiple screen sessions automatically?

I'm trying to build a command that launches screen, creates four sessions with different names, and run four different commands. I know how to do this manually: 1. screen 2. ./command1 args 3. CTRL-...
0
votes
1answer
14 views

Last background process ID ($!) not working in sudo bash command

Do shell variables work inside sudo executed commands? I'm trying to run, and later kill, a background process, as another user inside a script. However, I cannot capture the background process ID, ...
5
votes
3answers
2k views

How can I get zsh to display international characters properly?

I just started using zsh, and love it. However, I've stumbled upon an annoyance when it comes to international characters: ➜ ~ touch åäö.txt ➜ ~ ls ...
0
votes
3answers
2k views

How to make bash aliases available as linux commands?

I have many bash aliases on a remote location. But when I try to run those from my local linux box, I get the 'command not found' error. e.g. $ ssh root@remote 'status' bash: status: command not ...
1
vote
1answer
29 views

How to kill a daemon in Linux?

Note: Before you mark this question as duplicate, please note that I've tried all the solutions that I could get online, but still I'm unable to resolve the problem. I ran daemon through the ...
0
votes
1answer
11 views

Passing array values to command args

I’m trying to write a script which executes a command to each of the elements of an array, independently of the number of values in it. However, the only solution I come up with is the following (made ...
1
vote
2answers
27 views

gunzip multiple archives to specific folder

is there possibility to gunzip multiple files into one folder? I have alot of access logs which I need to exctract do folder. There placed in /var/log/nginx/ and they are named like access.log.2.gz ...
1
vote
1answer
16 views

bash xargs: same command gives different output

When I run ls -1 *.a | xargs -I{} echo {} | sed 's/.a//' The output is 1 2 3 When I run ls -1 *.a | xargs -I{} bash -c "echo {} $(echo {} | sed 's/.a//')" and the output is 1.a 1.a 2.a 2.a 3....
0
votes
1answer
10 views

Shell script fails when executed by systemd service

So I have a systemd service called startup.service: [Unit] Description=startup scripts [Service] Type=oneshot ExecStart=/home/user/Documents/Tools/Scripts/startup.sh [Install] WantedBy=multi-user....
0
votes
0answers
10 views

Run multiple Synergy servers

Currently I have a Windows PC & Linux workstation running Synergy. One is the client and the other is the server with the physical keyboard and mouse. I was wondering if it is possible to add ...
2
votes
1answer
14 views

Passing variables into ssh sessions (Session has to stay alive)

is it possible to start a ssh remote session and pass a variable to the remote host, which is usable in the opened session. For Example: Client: testvar="this is my text" Open ssh session (ssh user@...
0
votes
1answer
4k views

init.d script - Permission denied

I'm trying to create a init.d script for my server which should start/stop the teamspeak server and some node.js apps using "pm2". Here's my script: #! /bin/sh ### BEGIN INIT INFO # Provides: ...
0
votes
1answer
12 views

Difficulty getting /etc/rc.d/init.d tomcat startup script working

I have the following startup script that on reboot does not bring up tomcat: #!/bin/bash # # description: Apache Tomcat init script # processname: tomcat # chkconfig: 234 20 80 # ### BEGIN INIT INFO #...
1
vote
2answers
23 views

Can I delete only the first matching line using sed?

I have a file testfile.txt containing pippo=x pluto=y 1234=z I'd like to delete only the first line matching /^[a-z]\+=/ (the first line in this example). I've tried with the following command but ...
0
votes
1answer
17 views

create firefox profile in virtual terminal

As part of a system setup process, I'm trying to create a default firefox profile on the command line using firefox -CreateProfile default and then proceed to customize settings, etc. This works ...
-1
votes
1answer
18 views

Spotlight now treating bash scripts as 'Document' instead of 'unix executable'

I have a directory of bash scripts I use frequently, and I tend to launch these via Alfred Alfred in turn relies on Spotlight to index scripts, and assign them a meta content type of 'public.unix-...
15
votes
4answers
25k views

How to remotely write to a file using SSH

I can copy a file to a remote Linux machine with no problem with scp file user@host: /pathtowrite_file However, I'm having difficulty writing to a file from one linux machine to another. Here is ...
1
vote
1answer
40 views

Matching a randomly generated integer with a specific place value in a string

In bash I want to prompt user for input in a script. Lets say the input is: #!/bin/bash echo "Please enter a number." read NUM # User enters "12345678" How can I use the next command to generate ...
0
votes
2answers
28 views

Bash - sort by not first character

I want to sort my file by first column but I have to start sort from 5 character. How can I do that? My file: "TTTTCTTACA" 1 1 "TTTTCTTACC" 1 "TTTTCTTACT" 1 ...
43
votes
3answers
13k views

How do I reload .inputrc?

Background I have heard that the readline module is reading ~/.inputrc and that is how it changes the behaviour of keystrokes under programs such as bash. Question How can I reload this after ...
0
votes
2answers
29 views

cygwin bash - if statement doesn't work

I'm new to bash scripting, and I'm trying to learn on Windows, so I downloaded cygwin. Using Windows 10, cygwin v2.5.1 I made sure I installed the bash package (I did), and so I started going through ...
0
votes
1answer
11 views

Use netcat to bridge thru firewall?

I have a machine behind a firewall. It's my machine, I have set up ssh, but it's completely firewalled. My solution has been to use a reverse shell set up on a cron basis to reconnect if it fails ...
0
votes
0answers
11 views

Simple User Interface for video Interview [closed]

I would like to prepare a system to make interview at a party. Description of the interview We have a close room with a chair and a MacBookPro. Users come whenever it is free and record themselves ...
1
vote
1answer
20 views

Camel-casing a 'dashed' string

I'm fairly inexperienced with *nix scripting, and I have a need to take a string with lowercase words separated by dashes and convert that to a new string with the dashes removed, and the first letter ...
9
votes
3answers
5k views

rsync complaining about `missing trailing-"` in a Bash script

Trying to rsync files from one server to the other in a screen session. Instead of writing the long command every single time, I decided to put in a Bash script. However, when I run it, I get a ...
-1
votes
1answer
26 views

high priority for I/O operations

I came across this: http://linux.die.net/man/1/ionice however, it seems that it is not working on os x, as i got message that command not found. is there any alternative to it or way to install ...
1
vote
2answers
59 views

Ctrl-enter for fish shell

I had tried to create some accept completion and execute right away combination in fish on pressing Ctrl+Enter. function fish_user_key_bindings bind \c\n accept-autosuggestion execute end ...
1
vote
1answer
10 views

Fortran Compiler Installation Instructions for OS X

I try install fortran compiler for Mac OSX El captain. Firstly; I install install_f2c_osx.csh Run installation script $ chmod +x install_f2c_osx.csh $ sudo ./install_f2c_osx.csh It gives this ...
2
votes
1answer
22 views

How to delete a file from a command in a shell file for /etc/init.d?

I have a about question working with /etc/init.d shell script. All I want to do is delete a file from a command inside the shell script like so: case $1 in stop) echo "Stopping" rm -f /var/run/...
0
votes
1answer
12 views

tmux does not trigger when placed in rc.local

I want to start a tmux on boot on a raspberry pi - 2. I have written a session.sh file and I have places it in ~/bin/ file which is in the home directory. This ~/bin/ is also included in the $PATH and ...
1
vote
3answers
930 views

Docker on Conemu

I am trying to make docker run on ConEmu by creating a task that open up Docker start.sh file usinggit bash. Since normally docker Terminal is pointing to "C:\Program Files\Git\bin\bash.exe" --login ...
14
votes
8answers
7k views

Pushing my PS1 prompt over ssh

I use a specific PS1 prompt that I like. I share a few logins with other other people on a few different servers. I was wondering if there was a way to specify in my local bash profile a remote prompt ...
1
vote
1answer
53 views

Bash Scripting and quotation

I'm reading a couple of books on bash scripting, and struggling to understand proper quotation and the use of IFS. Perhaps someone can help me with a small example involving filenames with quotes. ...
13
votes
1answer
3k views

seeking to upgrade my bash magic. help decipher this command: bash -s stable

ok so i'm working through a tutorial to get rvm installed on my mac. the bash command to get rvm via curl is curl -L https://get.rvm.io | bash -s stable i understand the first half's curl command ...
17
votes
7answers
11k views

How to remove duplicated files in a directory?

I downloaded a lot of images in a directory. Downloader renamed files which already exist. I also renamed some of the files manually. a.jpg b.jpg b(2).jpg hello.jpg <-- manually renamed `b(3)....
4
votes
6answers
2k views

What is the simplest way to remove lines from one file matched with lines from another file?

What's the simplest way to remove lines from one file matched with lines from another file? For example, if I have the following files: file1.csv: u2@domain.com file2.csv: 1,u1@domain.com,...
3
votes
4answers
12k views

“command not found” when running a shell script. What did I break?

I'm on OSX Snow Leopard. Here's the full contents of grr.sh: #!/bin/sh echo wow When I try to run it from terminal: $ grr.sh -bash: grr.sh: command not found $ /bin/sh grr.sh wow $ sh grr.sh wow ...
2
votes
2answers
3k views

Changing the HOME for Cygwin

I'm trying to change the home directory for Cygwin on a computer at work. Our home directories mapped to a network share by default. This seems to cause some confusion for Cygwin, as it created a ...
0
votes
2answers
39 views

Is it possible to check for blips in internet using SSH tunnels?

So basically at work we're losing internet connectivity for just a few seconds at a time, which is enough to kill our SSH tunnels, kill our VoIP calls, etc. I have a cronjob set up with my own script ...
1
vote
3answers
265 views

WSL(ubuntu/windows) AppData\Local\Lxss doesn't actually sync back to ubuntu, ideas?

If you create a file in bash (touch /root/foo.txt) that appears in the hidden directories in AppData\Local\Lxss\ modifying it there does not change it in bash. Worse if you change it again in bash ...
0
votes
2answers
58 views

Importing variables in one shell script from another without executing the referred shell script

I have 2 shell scripts, file1.sh and file2.sh file1.sh #!/usr/bin/env bash export var1="/data/share" export var2='password' echo "Hello" file2.sh #!/usr/bin/env bash source file1.sh echo $var1 ...
4
votes
4answers
2k views

Can't rename a file the name of which starts with a hyphen

I'm trying to rename a file with a hyphen at the beginning of its name and both this: mv -example-file-name example-file-name and this: mv '-example-file-name' example-file-name result in: mv: ...
0
votes
1answer
896 views

How to run script before starting vpn connection?

I need to run a bash script BEFORE connecting to a vpn (which I do by clicking the network manager applet). I need this script because when connecting to the vpn the routes are incorrect. The script ...
2
votes
2answers
2k views

How to kill a continuous process started from rc.local?

I'm working on a Raspberry Pi with Raspbian (Debian-based) OS. For testing I added such a command in /etc/rc.local: python /home/pi/test.py It works fine starting this script. But the problem is ...
1
vote
0answers
20 views

Find windows program pid with its path

I want to kill a program with a windows bash script.I need to find the pid of a program with its path.we have three different directories with same program on a computer.We start all program all of ...
59
votes
4answers
96k views

Bash: Display each sub-directory size in a list format using 1 line command?

I want to get a list of the directories and their sizes in a list format like how you get when you do a ls -l. The thing is that is there a one line command that can do this? I see others have long ...