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

learn more… | top users | synonyms (1)

1
vote
2answers
53 views

Where to set bash settings for the user “mysql”

Please excuse me if the question is misleading. I'm trying to understand the way the environment settings work for the user "mysql". I'm following this guide to connect an Oracle DB from a MariaDB ...
2
votes
1answer
84 views

Is it possible to measure the used bandwidth per port on linux?

I am wondering if there is a way to measure bandwidth by a tcp/udp port under Linux? Means I search for a way to be able to tell, tcp/53 needs now 1MBit/s, tcp/80 needs now 4.5MBit/s. iperf is able ...
0
votes
1answer
87 views

How to list uid of all the users of LDAP?

I get list of all the users of LDAP using the following command ldapsearch -x -LLL uid=* > result. The result of the following command results in following format dn: ...
3
votes
2answers
182 views

Pressing Ctrl-C stops bash script, but don't stop PHP script called by the script

I need to run a few scripts every few minutes. The logic was made in PHP, and it's working great. To keep things together I've made the bash script below, which also runs fine. #!/bin/bash ...
1
vote
0answers
47 views

mysql-cli - force quit on timeout / connection drop

I have set timeouts in /etc/profile.d/ to disconnect inactive users using TMOUT and this works great however now I am seeing users just holding their connection open by keeping some foreground process ...
1
vote
1answer
270 views

Linux find: How to exclude the “.snapshot” directory from find's results?

I wrote a rsync script which uses find command to find all files which are older than 10 minutes and copies them to a remote server. The relevant part of the code is: print_log "------ Starting $0 ...
2
votes
2answers
71 views

Split large Logfile with Suffix like from logrotate

after I've seen that I forgot to add a logrotate-conf for php5-fpm.log on one Server, and now seeing that it has grown REALLY big, I'm asking myself how to split this Logfile into separate ones, with ...
1
vote
1answer
128 views

subshell is not created if run commands without a path?

I'm reading the book "Linux Command Line and Shell Scripting Bible" 3rd edition. On page 279, here I quote: "Command substitution creates what's called a subshell to run the enclosed command. A ...
2
votes
2answers
546 views

Why use `bash -c` in supervisor instead of calling script directly?

I'm beginning to use supervisord to control services in my server. I'm not a pro user of linux but can get with it quite well and get it running. Just out of curiosity, I've noticed that most ...
3
votes
2answers
111 views

top output to narrow in cron

I'm trying to send an email through cron to know what processes are hogging my server. It works fine but the resulting email is too narrow and I need to know more about the process. This is the ...
2
votes
1answer
72 views

How to check root environment variable from sudo user?

How I may check root environment variables from sudo user? I tried various keys and combinations of su and sudo, but have no luck. For example, $HISTFILESIZE=2000 for ordinary user and 9999 for root ...
1
vote
3answers
150 views

How execute perl one-liner from perl script (properly escaped)

I have a perl script from within which I need to execute a simple perl one-liner on a remote host: ssh 192.168.1.1 "perl -pi.bup -e 's/^(\s+?kernel)(.*)(?<!audit=1)$/$1$2 audit=1/' /etc/grub.conf" ...
0
votes
1answer
106 views

Script Works in Terminal, but Not as .sh

I have a script that works in the terminal perfectly, but for some reason won't fire off either in cron or when I run the script manually. I don't know if it makes a difference, but it's running on ...
-1
votes
1answer
52 views

File encryption when limited in storage

Assume: On Linux server we have limited free space. The task is to create archive of a folder (for example /var/www), encrypt it and upload to remote location keeping original unencrypted file in ...
6
votes
1answer
589 views

How to protect from dangerous bash commands? [closed]

When using bash with or without sudo there are many traps. For example when logged in as root between rm -rf ~/bin and rm -rf /bin there is just one character but this difference can make you ...
0
votes
3answers
60 views

How to ssh and use a personal bashrc without getting disconnected

I would like to be able to ssh to a remote host and run some repetitive commands on it before continuing my work. I have been trying the following command with no luck: ssh uname@remotehost.com ...
1
vote
2answers
73 views

User created with useradd instead of adduser loads a wrong Prompt

I've designed my bash prompt like this \u@\h> When i now create the User example with adduser, my prompt looks like example@host> But when i create a User with useradd, my prompt looks like ...
0
votes
2answers
50 views

Read cron schedule from bash script

Is it possible to get the schedule for a running job? If i have this line in my crontab * * * * * /home/test/test.sh Can i read the * * * * * from test.sh, and only for that script? I hoped there ...
1
vote
1answer
101 views

gzip select directories into separate archives

How would I go about compressing a list of directories into separate archives? I have read solutions that just archive all the directories within a given dir, but there are some I want to skip. ...
0
votes
2answers
121 views

Bash move and rename folders

I have a bunch of folders like that: Team A - Folder 01/ Team A - Folder 02/ Team B - 14-12-2003 - Folder XX/ Team B - 21-03-2008 - Folder YY/ ... With the passing time, this list have became very ...
0
votes
1answer
29 views

Searching for files containing text (not string) in bash

How do I find files containing some particular text containing newlines and plenty of other charachters all sorts of quotes and backslashes using terminal?
1
vote
2answers
74 views

Get a file's ctime, atime, mtime and extended attributes

I would like to display a file's ctime, mtime and atime along with whether it has extended attributes or not. There are 2 commands that can do this but I have not been able to combine them into a ...
3
votes
3answers
68 views

How can I delete old log files?

I'm trying to figure out how can I delete old log files, I'm using Centos 6.5 and in my /var/log I see these old log files messages messages-20150802 messages-20150802 also the same in the ...
0
votes
0answers
36 views

Terminal piping misunderestanding

Folks I have a few questions around this command: echo 'cat //item/*[local-name()="id"]/text()' | xmllint --shell test.xml | sed '1 d;$ d;/^ -------$/ d' | sort | uniq --repeated I thought command ...
0
votes
1answer
135 views

Get all files/directories created before a certain date?

We have a samba share on an Ubuntu box that an office full of macs use. Something has happened recently and various folders now seem to have a created date of 1984 and are greyed out/inaccessible for ...
3
votes
1answer
135 views

The file and dir sizes of du -hs * is not consistent with du -hs

When I run the bash command du -hs ., the output is 1.2G . When I run the bash command du -hs *, the output is 108K action 4.0K activate.php 8.0K browse.php 584K captcha 164K ...
0
votes
2answers
346 views

How to execute bash script through pxe boot [closed]

Can any one tell me how to execute bash scripts via pxe boot. What I am trying to do is when Raw Server boots up I want to deploy cloned image over hard disk via PXE boot. I am aware that there are ...
0
votes
2answers
69 views

Limit user to access only 'docker inspect'?

Is there a way to give access for a user (www-data to be exact) to access ONLY 'docker inspect'? Any working solution is acceptable
0
votes
1answer
135 views

How to set Cron Job to empty cached directory

I have plain Ubuntu based server, i want to set Cron job and it will empty my website cache directory in every 24 hours, due to massive records 'rm -rf ' not work, so manually i used 'find . -name '' ...
0
votes
2answers
113 views

sftp returns code 0 even if there is an error reported “Couldn't create directory: Failure”

I am trying to write a Bash script responsible for creating a folder on a remote server. Snippet: !/bin/bash -e echo "Creating remote folder." echo mkdir test_folder | sftp -oPort=22 ...
1
vote
2answers
201 views

How does this variable escaping work in a systemd unit file?

I have a fairly simple unit file for a discovery sidekick service for a server instance I'm running on CoreOS. The unit file looks like this: [Unit] Description=Discovery for frontend server ...
1
vote
1answer
51 views

Python script crashes when run via Cron

I have a python script that completes exactly as expected when run manually as the root user. When I put the script into cron.daily it crashes 100% of the time. The error is a timeout error, but ...
0
votes
2answers
38 views

Amazon Linux : Autoscalling server deleting policy

I have tried many things but not able to save my files. I have an account in aws and I have created an autoscaling group.I want to copy my log files to s3 but when any of the server deleted ...
-2
votes
2answers
179 views

how to replace one url with another using sed inplace replace in multiple files?

As you can see in the script example down there, I'm trying to find and replace (inplace replace) a string which is part of an URL with another string (url part) within ALL files found with that ...
-1
votes
2answers
397 views

How to reload environment variables from within a script

I would like to be able to regenerate the value held by the environment variables inside my testing environment, and have the new values be read by PHP-FPM. I have written a script that regenerates ...
0
votes
4answers
129 views

How do I delete the contents of a directory if there are spaces in the path?

find -name "lastStable" -o -name "lastSuccessful" -exec sh -c "sudo rm -rv {}/*" {} \; As you can see from the above command, I am going through and deleting the contents of the lastStable and ...
0
votes
2answers
27 views

Move all ls output and symlink

I want to move some of my files in directory to another drive and create symlink for each of them in the old directory that will point to the new directory. For example, [root@localhost olddir]# ls ...
1
vote
1answer
69 views

Solaris + date + what is the same equivalent for Solaris

on Linux the syntax for date with seconds is: date +%s 1438587288 from MAN PAGE - %s seconds since 1970-01-01 00:00:00 UTC what is the same equivalent for Solaris?
-1
votes
1answer
240 views

Bash add entry to fstab by script [closed]

I'm newbies in bash scripting and i try to write script that add entry for cifs windows share to fstab. I writed a litle script but i'm not shure if it will work fine. I haven't linux to test it Can ...
2
votes
1answer
267 views

linux + at command + how to kill the job

I use the at command in order to run the task (test script ) every one min at -f /tmp/test now +1 minute commands will be executed using /bin/tcsh job 1438153690.a at Wed Jul 29 10:08:10 2015 ...
0
votes
2answers
173 views

top command + how to verify iowait value for one hour

my target is to check iowait value that not higher than 50 from top command and if value is higher than 50 for more then one hour , then need to give alarm about this ( by script or other option ) ...
0
votes
1answer
33 views

Pass output of an expression to the standard input of another program

I'm trying to generate some data to pass to another program, which takes the argument from standard input, and requires confirmation of that argument. How do I do this in bash? From the manual ...
0
votes
1answer
22 views

Bash find file with specific permission for group, no matter permission for user and others

Using only octal notation, I need to find file that have only read permissions for group, no matter which owner and other permission are. Which is the right command? I can't find it. Thank you.
0
votes
0answers
27 views

bash scripting and comparing 2 directories - Beginner [duplicate]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
1
vote
0answers
51 views

bash scripting comparing 2 things [closed]

My problem is that i have to check what files are included in the $directory, then i have to make a new file with name specified by me and compare if the name doesn't already exist in this directory ( ...
0
votes
1answer
222 views

cron and lftp issue

I have the following scripts running on raspbian. start #!/bin/bash /root/config/commands 2>&1 > /root/log/$HOSTNAME.log commands #!/bin/bash source /root/config/variables echo TestLine ...
1
vote
4answers
134 views

find command with parameters in variable

> find /etc -name 'shells' /etc/shells # good !! > SEARCH="-name 'shells'"; find /etc $SEARCH # nothing found - bad !! Why "find" command can't take params in variable? Other commands ...
0
votes
1answer
49 views

find files which are not currently in use

I'm trying to archive some older files, but don't want to touch all the files which are currently in use. What's the best way to ask find to exclude "in use" files? Right now I'm working on this ...
0
votes
1answer
89 views

OpenSCAP incorrectly reporting false for RHSA-2014:1306: bash security update (Important)

I'm using the following command to test for RHSA-2014:1306 on CentOS 5.9: oscap oval eval --id oval:com.redhat.rhsa:def:20141306 com.redhat.rhsa-all.xml The result is: Definition ...
0
votes
1answer
24 views

Is there a way to prevent the Screen progarm from killing all windows?

I have a server application whose output is can be viewed through the Screen application on linux. However, I noticed when using the command-line application I noticed that this command can terminate ...