Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

learn more… | top users | synonyms (1)

0
votes
0answers
18 views

udev set kdbrate settings on linux with console users issue

I have a kbdrate setting as a udev rule for usb devices(keyboards and scanners that re repluggd in). kdbrate needs to be set by someone with /dev/port access which is the console user. The udev rule ...
-1
votes
1answer
24 views

Bash and cron error [duplicate]

The following cron job fails to execute. What's wrong with it? It works fine when I run it directly from the shell prompt. www-data@etl:~$ crontab -l SHELL=/bin/bash MAITO="" 0 5 * * * export ...
0
votes
2answers
26 views

Check if remote mysql query was successful - bash

When using a bash script to execute remote MySQL queries, how can I know if the command was successful or not. Locally it would return an exit code. However, remotely it seems to send the query and ...
0
votes
3answers
23 views

How can I copy all files in one tree to another tree except those matching a pattern?

I have a directory tree under ./src/ I have another matching directory tree under ./work/ I'm trying to copy all the files in src to work, while keeping the directory structure and excluding all ...
1
vote
0answers
27 views

Capture transcript of program with redirected input and output [migrated]

A typical interaction for a program I've written might look like this: Enter command: a_command Completed a command Enter command: another_command Completed another command I typically run my ...
5
votes
6answers
2k views

how do I make solaris shell more familiar for a linux user? [closed]

I've been a linux user for years. Very used to the bash shell, used to linux shell key mappings that come with most mainstream distros. I'm also a happy vim user in linux & love my arrow keys. ...
-1
votes
0answers
34 views

Shell vi mode prints (arg: repetition): How to remove it? [migrated]

Whenever you are in vi command mode on the shell and hit a number, like 8, "(arg: 8)" shows at the start of the line. Anyone know how to make it not do that? The moving the line I'm typing is ...
-1
votes
1answer
20 views

how to set linux hostname based on flashdisk volume label [on hold]

i'am running live linux, which run from FAT32 flashdisk since i run a lot of pc using this flashdisk, its difficult to identify which IP for its hostname, since its ip need to be dynamically ...
0
votes
1answer
18 views

Bash/grep: ignore lines over N characters

I have a find/grep command that i use to search my projects' codebase, thus: find folder1 folder2 folderetc -print | awk '{print "\""$0"\""}' | xargs grep -n "search-string" Something that ...
2
votes
3answers
625 views

Regular Expression matching in ssh config

I have a bunch of servers with the names srv1.domain.com, srv2.domain.com, ..., srv50.domain.com I want to be able to connect to these servers by ssh srv1 I don't want to put 50 configuration ...
54
votes
7answers
71k views

How do I get current Unix time in milliseconds using bash?

How do I get the current Unix time in milliseconds (i.e number of milliseconds since Unix epoch January 1 1970)?
0
votes
1answer
45 views

Eliminate need for grep use only awk

I am trying to generate a list of PID's to pass to strace I only want the PID's php-fpm. I can get the correct output by using grep with awk but am looking for an awk only answer. Here is what I ...
1
vote
1answer
733 views

Linux- Permission denied?

I'm installing Neo4j server as a linux service, but when I install it, I get the following message: /sbin/insserv: Permission denied What is this? What should I do? I'm running everything with ...
3
votes
2answers
2k views

Execute a command when a device is connected via USB

I currently have a system that backs up my Linux server onto a USB storage device on /media/usb. This all works correctly. However, I actually have 2 drives which we try to swap on a daily basis. Is ...
5
votes
9answers
10k views

'Argument list too long' error while copying a large number of files

I am using the following command: \cp -uf /home/ftpuser1/public_html/ftparea/*.jpg /home/ftpuser2/public_html/ftparea/ And I am getting the error: -bash: /bin/cp: Argument list too long I have ...
-1
votes
0answers
11 views

touch -d alternative in MAC OS X [migrated]

I need to change modification time of all my files in a folder 1 hour back (daylight saving issues with some software) The thing is that touch -m -r {} -d '-1 hour' Doesn't work on MAC OS X Any ...
0
votes
0answers
37 views

wget failing when I enter variable name in command [migrated]

I have a small bash script to download a file from my webserver. I pass the $File variable through the command line and then insert it into the wget command as follows: File=${1} wget -a ...
9
votes
6answers
9k views

From a shell script, how can I check whether a MySQL database exists?

mysqladmin -uroot create foo returns an exit status of 1 if foo exists, and 0 otherwise, but of course it will also create the database if it doesn't already exist. Is there some easy way to simply ...
11
votes
1answer
276 views

Can Bash Tell Me Which SSH Public Key Was Used To Authenticate?

Let's say I want to track my root users. Each of them has a unique private key and their public keys have been stored in /root/.ssh/authorized_keys. Given that each user logs in with their unique key ...
0
votes
1answer
772 views

Improper output in SSH session on OSX using FreeSSHd on Windows with cygwin bash/sh shell

I am testing out running an SSH server on a local Windows VM. I have installed FreeSSHd and set the command shell to "c:\cygwin\bin\sh --login -i" (bash as well) with "Use new console engine" ...
1
vote
1answer
38 views

How to programatically find default ssh key?

In most of my experience, by default, ssh will look in ~/.ssh/id_rsa(.pub) for the default key pair. Ocassionally I try to write scripts to take advantage of this default key location, but I end up ...
0
votes
2answers
49 views

Capture piped multiline grep output into a variable

I'm using Zabbix's zabbix_sender.sh script to push exception stack traces to my remote Zabbix monitoring server. zabbix_sender.sh requires a key and a value for any data that it sends. It can read ...
0
votes
1answer
789 views

How do I correctly SSH port forward using LiveReload on Redhat?

Referencing this page: http://feedback.livereload.com/knowledgebase/articles/86280-if-you-edit-files-directly-on-your-server It says you can remotely port forward the LiveReload specific port of ...
1
vote
3answers
67 views

How do I restore the default bashrc?

I have accidentally overwritten .bashrc. I did the following echo 'export EDITOR=/usr/bin/nano' >> /etc/bashrc Bur I accidentally typed > instead of >>. I guess, it was a bad idea. I ...
1
vote
3answers
59 views

Batch rename files that end in a dot

I have a large unix fileserver, with a single large SMB share. It serves to Mac, Linux and windows clients. A large portion of the files on this box have been migrated there from a Mac Xserve. One ...
6
votes
1answer
108 views

Providing normal users(non-root) with initialization and shutdown auto-run capabilities

I'm hosting an experimental/testing Linux box, running Debian Wheezy 7.4.0 distribution. Different users log into the machine over ssh to their accounts and are allowed to run the development tools ...
1
vote
2answers
535 views

I can run a script locally, but cannot do “ssh HOSTNAME /path/to/script.sh”

I have a linux server, and a linux desktop. I have written the following simple script to dump the database of a django web application: #! /bin/bash set -o errexit cd $(dirname $0) . ...
2
votes
4answers
139 views

Starting a script as another user

I've created a script in /etc/init.d/ which has to run several other scripts from other (non-root privileged) users from their home directories, as if they started them. I launch these scripts ...
1
vote
0answers
8 views

screenrc subshell for every window [migrated]

.screenrc: shell -${SHELL} caption always "%n(%t) %= %{b}@%H[%l] : %{r}%c:%s" termcapinfo xterm ti@:te@ termcap xterm 'AF=\E[3%dm:AB=\E[4%dm' terminfo xterm 'AF=\E[3%p1%dm:AB=\E[4%p1%dm' ...
4
votes
3answers
2k views

Run an interactive bash subshell with initial commands without returning to the (“super”) shell immediately

I want to run a bash subshell, (1) run a few commands, (2) and then remain in that subshell to do as I please. I can do each of these individually: Run command using -c flag: $> bash -c "ls; ...
-1
votes
0answers
49 views

What are ways to encrypt a password inside an environment variable [migrated]

I have this file I use to set my username and password before exporting the value. #!/bin/bash echo -n "User:"; read user echo -n "Password:"; read -s password export ...
0
votes
1answer
39 views

Finding a user's home from bash

I'm trying to get the value of a user's home from a puppet script. This particular user is a Samba user, not a local one, with the username of the form DOMAIN\user. I've tried the following, with no ...
1
vote
4answers
954 views

How to pass a password with punctuation characters to 'mount' command?

I have a shell script that mounts several samba shares one after the other. I want my users to have to enter in their password only once. I can pass in a password using the following, mount -v -t ...
5
votes
3answers
3k views

Determine if file is in the process of being written upon?

I need to deploy an automated process (via 1 min cron script) that looks for tar files in a specific directory. If a tar file is found, it is untarred to the appropriate location and then the tar file ...
1
vote
1answer
43 views

Get some meaning from apache logs with awk and grep [duplicate]

I am trying to have some meaning from my apache log files: I want to parse my access log and have some statistics about 200 status code hits (how many times each of them was hit). So I tried to learn ...
1
vote
0answers
9 views

SNMPget and bash gives strange results (gauge32 values incorrect)

Reallly strange to me but here is the problem. If I use an SNMP client such as ManageEngineMibBrowser to query the appliance I get what look like reasonable Numbers: dpStatusMemoryStatusUsage.0 97 ...
2
votes
4answers
844 views

Handy parsing for numbers with unit suffixes?

Let's say you have data with quantities in human-readable format, such as the output of du -h, and want to further operate on those numbers. Let's say you want to pipe your data through grep to do a ...
3
votes
1answer
461 views

Can i call pushd/popd and prevent it printing the stack?

After calling pushd/popd in bash, it will print off the current directory stack. Is there any way to prevent this behaviour, so that it will act 'quitely'? This sort of noise in a command is uncommon ...
1
vote
0answers
15 views

Setting tabstop for bash output [migrated]

Is it possible to set a tabstop (number of spaces per tab) for the more and less commands? In vi, I've added this line to .vimrc set tabstop=4 However when I read through a file with more it still ...
3
votes
1answer
33 views

Bandwidth Throttling using tc qdiscs

I am trying to limit the bandwidth between a simple iperf server and client, using a third, passive machine acting as a bridge. With no interference, iperf returns a bandwidth of ~90 Mbits/sec. My ...
0
votes
1answer
36 views

How to set ulimit in chroot with --userspec

I have script to create a minimal chroot (below), but I can't figure out how to get ulimit to work on the chroot'ed process: #!/bin/bash user=$1 apps="$2" cmd_to_run="$3" shift 3 ...
1
vote
3answers
60 views

Any Linux tool to create a repo file?

SuSE's package manager zypper is able to create repository file in /etc/zypp/repos.d/. zypper -n rr myrepo zypper -n ar -f http://path/to/myrepo myrepo I'm looking for an equivalent tool do the ...
1
vote
0answers
38 views

Using 'find' to email me those files modified recently [migrated]

I'm using 'find' at the end of a script to email me any .log files in the current directory that have been modified in the last 6 hours. I need this because the file names change so I can't be any ...
0
votes
0answers
15 views

Script to apply Simple Finder restrictions to Mac OS X user?

Is it possible to script (e.g. with AppleScript or bash shell script) applying the Simple Finder and an associated application whitelist to a local user account on Mac OS X? We are using Mac OS X ...
1
vote
2answers
9k views

bash script - spawn, send, interact - commands not found error

I my shell script, I am trying to remove password prompt for scp command (as given in http://stackoverflow.com/questions/459182/using-expect-to-pass-a-password-to-ssh/459225#459225) and this is what I ...
1
vote
3answers
704 views

Cannot remove or list directory (ls or rm) Linux - Debian

I have a log file directory at /var/log/apache2/vhosts on a Debian dedicated server. Every day I split the main access_log into respective vhostname.com_access_log files in /var/log/apache2/vhosts In ...
-4
votes
1answer
31 views

Killing a bash sh script [closed]

I made an .sh file load.sh which has (almost) unlimited loop of curl requests. I run this as $ bash load.sh. Now it just keeps running the loop. I can't cancel its execution. It keeps running. I ...
0
votes
2answers
33 views

Creating an environment variable for a specific user

When you set an environment variable in linux is it set only for the user who executes it, or can you specify a user when you store it, or instead is it always available for all users?
2
votes
0answers
27 views

Symlink all subdirectories in a directory to another directory [migrated]

I'm trying to symlink every directory in a folder to another folder. For example, in the structure below, I need the subfolders symlinked to folder2. - /home/chris/folder1 -- subfolder1 -- subfolder2 ...
3
votes
2answers
458 views

How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that

I need to backup data and config files on this server, daily. I need to keep: daily backups for a week weekly backups for a month monthly backups for a year yearly backups after that All of this ...