Questions tagged [bash]

Bash (Bourne-Again SHell), is the default interactive user shell used in Ubuntu. Use this tag for questions specific to Bash, as opposed to generic POSIX shells.

Filter by
Sorted by
Tagged with
-1 votes
2 answers
1k views

wget to download files from list of urls and naming it from other list of names

I Have two text files - one of them contains urls of images that I want to download and other text file has the list of names corresponding to the urls of first files. Example content of text file 1: ...
19 votes
1 answer
44k views

Docker Compose can't execute: "Command 'docker-compose' not found"

I have installed the latest Docker Compose as a non-sudo user on Ubuntu Server 20.04 along with docker-rootless daemon in the non-sudo user's directory, using the following: mkdir -p ~/.docker/cli-...
1 vote
0 answers
1k views

WSL Ubuntu 20.04 is giving errors when installing zathura and other programs [duplicate]

I am trying to install zathura, and this operation has worked fine for me on the Windows WSL2 Ubuntu-18.04. However, when I installed Ubuntu-20.04 in its stead, I keep getting errors like these which ...
0 votes
0 answers
43 views

bash: ./run: Permission denied

The source code of the GOLIATH simulator and installation guide are provided in public. https://github.com/necst/GOLIATH However, I found it hard to install it. I got permission denied error as ...
0 votes
0 answers
73 views

How to start a named background process when using bash?

I have a script that looks like this: #!/bin/bash tsx watch services/$1/src/index.ts This will start tsc for the given service: script/start_service some-service If I add & the end it gets ...
0 votes
0 answers
33 views

Script ideas for configuring VPN connection

After some bad crashes of my system, I decided to take a more organized approach and develop a bash script that will handle most of the things I tend to configure manually after a fresh installation (...
-1 votes
0 answers
51 views

Variable returning empty in logon script

I'm trying to make a script that runs when the user logs in, to change the wallpaper. I run the script at logon, the script is inside the /etc/profile.d/ folder. I use ImageMagick to write the PC name ...
0 votes
0 answers
29 views

unattended bash script (*.sh) with password

I want automatically made full image backup from any servers. Manually it works like: ssh [email protected] "nohup sudo -S dd if=/dev/sda | gzip -1 -" | dd of=fullServerXX-`date +%d%m%y`....
0 votes
1 answer
56 views

changing grep command --color from red to another color [duplicate]

I'm searching from the file using grep command with particular pattern, sysadmin@localhost:~$ grep bash /etc/passwd which return the output like below root:x:0:0:root:/root:/bin/bash ...
0 votes
0 answers
41 views

here file does not fill token

I use a certain command quite frequently, but the command prompts a few things so I wanted to auto-fill it with here file, but it seems that for some reason it can't provide last value to the prompt. ...
0 votes
1 answer
59 views

What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob?

I need zsh equivalent to bash's shopt -s globstar and shopt -s dotglob. How can I do that? UPDATE 01: As per @muru's answer, I used setopt globdots in the zsh shell, and ran the following command: for ...
0 votes
1 answer
37 views

Invoke a program as a command on any working directory on ubuntu's terminal [duplicate]

I have written a program in C and produced an executable from it. I want to use this program from any pwd. One method is to make its pathname a environment variable using export. But in this method, ...
2 votes
2 answers
482 views

Linux copy command with multiple options

I know this is probably a real simple question, but I want to copy newer files from one server directory to another and preserve the datestamp. I've tried cp -p /source/records_added*.csv /dest/...
1 vote
2 answers
185 views

Changing Linux file names to NTFS-compatible file names [duplicate]

I must create a bash shell to rename the file names in a directory structure. In case the file name contains \ or : or a space it should be translated to _, _, and - respectively. I'm trying to use a ...
6 votes
1 answer
325 views

Regular expression to match a concatenation of fixed strings, and alternative expressions

I mean to match (with ls, rm, etc.) files with names test10 to test18, test30 to test38, test22 to test23, with a single regex, in bash. I tried many variants around $ ll "test([1,3][0-8]|22|23)&...
3 votes
0 answers
85 views

Making an ISO from a dvd once it's inserted

I'm trying to make it so that when I insert a dvd into the cdrom It exports it into an iso using dd. Here's the script for exporting to an iso #!/bin/bash timestamp=$(date +"%Y%m%d_%H%M%S") ...
4 votes
3 answers
2k views

How to exit gpick color picker after picking from a keyboard shortcut?

I assigned a shortcut in Ubuntu 14.04 to gpick -p, which brings up the color picker instantly. GPick is configured to save the picked color to the clipboard. However, once the color is picked, the ...
2 votes
1 answer
887 views

Terminal: I can't type anything

I am on Ubuntu 22.04 and I was trying to download updates but my machine glitched, I couldn't do anything, waited for a few minutes, and then had to force off the machine by holding down the power ...
39 votes
4 answers
95k views

How do I select a field/column from the output of `ls -l`?

My goal is deceptively simple (at least to me). I wish to take the output of ls -l or ls -lh and select just one field. I am looking for this to be as bulletproof as possible, by which I mean, assume ...
141 votes
12 answers
335k views

Home directory not being created

I am trying to understand system administration on Ubuntu. So, as an example, I create a dummy user using sudo useradd -d /home/linda linda and passwd to create the password. I check that an entry ...
26 votes
9 answers
6k views

How to fix "chmod" permissions after running "chmod 222 /bin/chmod"?

I ran chmod 222 /bin/chmod to know more about chmod. After that, when I run /bin/chmod, I get permission denied. I tried to change the permissions of chmod back to 755, but it doesn't work. Does ...
0 votes
1 answer
42 views

Start @reboot crontab script in a new tmux/byobu session and be able to connect to it

I have a crontab entry that starts a backup job script after reboot: @reboot (sleep 120 && bash /srv/recvuser/cron_autostart.sh) 2>&1 | /usr/bin/mail -s "SuperServer ZFS Backup&...
1 vote
1 answer
116 views

accidentally moved almost all my files in a new directory, is it the end for me?

I was working on a big Latex project and I wanted hide all the file which are not .tex, .pdf, or .png to see clearer in my directory browser. I used the following script : #!/bin/bash # Create a ...
1 vote
0 answers
136 views

Rsync over SFTP alternatives?

I am currently working with an SFTP server and aiming to synchronize its folder with a corresponding local directory. It's crucial to note that I lack control over the SFTP server, and files within it ...
0 votes
1 answer
38 views

I accidently changed my root user's name and now have lost all root permissions

I was messing around on my minecraft server with usermod and at some point I copied a command from a forum with incorrect terms. now when I sudo cat /etc/passwd, the output for my root user is as ...
21 votes
5 answers
6k views

How do I rerun the second-to-last command?

I'm using Ubuntu 21.10. If I mess up, I can re-run the last command with !!. Here's an example: $ apt update Reading package lists... Done E: Could not open lock file /var/lib/apt/lists/lock - open (...
30 votes
1 answer
56k views

how to set icons and theme from terminal?

Is there a way to set active icon theme and GTK theme from a terminal? I would like to write a script that installs and sets everything up the way i like it on a fresh install.
0 votes
0 answers
56 views

Bash not working in TTY/gnome-termina/Xterm

I opened the terminal today and all I could see was this white blinking bar: I opened Xterm and there is the same problem. Also, TTY doesn't work well, I can login and then I cannot type anything. I ...
1 vote
0 answers
279 views

How to to run multiple clones in parallel?

Since I am working on KVM, I have encountered an issue while trying to run multiple scripts in parallel that calculate the time that each VM takes to be cloned from an image that exists on the same ...
1 vote
2 answers
1k views

How can I detect when the boot sequence is complete on headless system

I have a CONF file in /etc/init to configure and start software on my headless machine. When a monitor is attached for development and testing I see that my software starts near the end of the boot ...
165 votes
10 answers
232k views

Arrow keys, Home, End, tab-complete keys not working in shell

I have installed ubuntu minimal(mini.iso) on my vm. I then used recovery mode to login as root and create an account with useradd -m admin and then set a password with passwd admin. When I login on ...
1 vote
0 answers
36 views

How to add my own shell script to be able to be autocompleted in terminal by Tab

I have bunch of shell script (.sh) command created in a folder ~/bin, I added this path to .bashrc so I can execute them wherever I like. i.e. a sample command to create git feature branch based off ...
0 votes
2 answers
412 views

notify-send to other user by crontab

I have script what is running by crontab but as su, at some point is possible that it will send notify by notify-send but I want to this to specific user (login is in $2, but only one will be logged ...
0 votes
1 answer
33 views

Custom alias to run and compile .c file [duplicate]

I'm trying to create custom alias to to compile and run my .c files in one command. I tried to add this line in /.bashrc_aliases alias runc='gcc $1 -lm && ./a.out' however I get an error and ...
2 votes
1 answer
99 views

Special characters 158 and 159 stopping my functions in terminal

I am having issues with the two special characters 158 (U+009E "Private message") and 159 (U+009F "Application program command"). My issue started with a function in Clisp that I ...
0 votes
0 answers
26 views

Scrollback lines on SSH session with Ubuntu 22 minimal server

I've installed a new minimal Ubuntu 22 server on hardware and am now SSH'ing to it from a local network PC - however I note that the output in the ssh window (Terminal on MacBook Pro) is limited to a ...
0 votes
0 answers
93 views

How can I run different commands in separate terminals using a shell script?

I have access to an Azure VM where I intend to run three Hyperledger Besu nodes: one boot node and two validator nodes. To automate this setup, I've created a shell script. First, I checked the ...
1 vote
1 answer
6k views

How to resolve java : not found?

I execute the command sudo cassandra -R to start cassandra and I get the following error. getopt: invalid option -- 'R' /usr/sbin/cassandra: 158: exec: java: not found It points to the following ...
0 votes
1 answer
71 views

Backporting: Does anyone have a function to mimic bash 4 associative array?

I need to make changes in my script that uses associative array, so that the script may be used in older versions (before v4.0) of bash which did not support associative array. Can someone suggest how ...
35 votes
5 answers
11k views

How can I run the original command that I also have aliased with same name?

I have an alias for the ls command in my ~/.bashrc file aliased with this one: alias ls='ls --color=auto' When I run the ls command in a terminal, the aliased ls (ls --color=auto) runs. My question ...
2 votes
1 answer
3k views

How to implement a text based quiz using Bash?

Is there a decent way of implementing a quiz in Bash, where the questions are randomised each time and where the users' different responses (correct, wrong, pass) are recorded and then given at the ...
60 votes
7 answers
68k views

How to make LV use all disk space in PV?

During the installation of Ubuntu Server 20.04.1 LTS I chose to use the entire disk as partition (default partitioning that's recommended for beginners, since I don't need any other partitions anyway. ...
15 votes
5 answers
16k views

Control-R stopped working, I have to press Control-Shift-R instead

Before, I could hit Control-R in GNOME Terminal to enter Bash's (reverse-i-search) mode. However, this stopped working, the cursor just flashes without doing anything. This also affects remote and ...
5 votes
2 answers
450 views

highlighting specific lines in different colors when starting a scipt with printf

I am using a bash script. When I launch my script, how can I highlight specific lines on the output? For example, all lines with "Enable" should be green, all lines with "Disable" ...
0 votes
0 answers
29 views

dpkg; unrecoverable fatal error 'plocate'

dpkg: unrecoverable fatal error. unknown system group 'plocate' in statoverride file; the system group got removed before the override,which is most probably a packaging bug
3 votes
2 answers
126 views

Ubuntu terminal ignoring interpreter first line

I am Windows user running WSL2 with success over the last two years. I work on a project connected to a git repository. All devs work on mac/linux so all parts of this project are targeted towards ...
2 votes
0 answers
74 views

Symbol gets cut off in custom bash prompt

I am using a custom bash prompt with this command that was an answer to this question: It looks like this: PS1=$'\e[1;33m\\t \e[36m\u\e[34m@\e[36m\h\e[;1m: \e[34m\w\n \[\b\e[;1;31m✘\] ${?/#0/\[\b\b\e[...
0 votes
1 answer
70 views

Trivial pursuit : bash environment variables

I know this works: FNAME="$(basename $LD_PRELOAD)" FNAME="${FNAME%.*}" Can this be expressed in a single line? These are two unsuccessful attempts, thus far: ${$(basename ...
73 votes
10 answers
120k views

How to run scripts without typing the full path?

I'd like to know if there is a way to run program/shell script without typing full path: /opt/idea/bin/idea.sh
7 votes
2 answers
1k views

Should I put functions in .bashrc, .bash_aliases or .profile

I have read this thread about where to put aliases. Now, let's suppose that my custom command is quite elaborate (takes arguments in input, is composed of several commands run one after the other, I ...