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
2 votes
1 answer
439 views

non-login shell sources $HOME/[.local/]bin to $PATH and I can't find why

OS: Ubuntu Desktop 22.04 I am initially logged in as user carl. I open a shell and echo $0, I get the confirmation that I am in a non-login shell. ("bash", no dash) But when I then echo $...
2 votes
1 answer
5k views

How to run script on startup with root

I have my little script to start an application and do some more things on my Ubuntu 16.04 which looks like this: #!/bin/bash ./ROC-smi/rocm-smi -d 1 --setfan 90 ./ROC-smi/rocm-smi -d 0 --setfan 90 ./...
4 votes
2 answers
703 views

PPA GPG key from bash script

Let's suppose that I have a fresh install of Ubuntu 21.10 and that I want to add my preferred PPAs from Launchpad. I know that I can use the add-apt-repository, but it does not currently add the PPA ...
-2 votes
1 answer
89 views

Firefox Developer Edtion Don't show a icon in menu bar and task bar of Ubuntu. Even changing the .desktop file in /usr/share/application

I want to install a Firefox dev in bash, but I see this problem with an icon in the GNOME shell. If open the normal Firefox, in the top bar appears a grayscale icon: If you can help me I would ...
0 votes
0 answers
81 views

Avoid logging empty commands in Bash

I am using the following lines at the end of my .bashrc file to log entered bash commands to Syslog: export PROMPT_COMMAND=' RETRN_VAL=$?; if [ -f /tmp/lastoutput.tmp ]; then LAST_OUTPUT=$(cat /...
3 votes
1 answer
4k views

i want to install specific version of go programming language(1.7.5 ) in ubuntu 16.04

wget https://storage.googleapis.com/golang/go1.7.5.linux-amd64.tar.gz extract the package sudo tar -zxvf go1.7.5.linux-amd64.tar.gz -C /usr/local/ Added by Go Path echo 'export GOROOT=/usr/local/...
-2 votes
1 answer
93 views

Write a Bash Command File for OpenFoam to periodically change an entry

I am trying to use an OpenFOAM case called ConstVolt_0flow where I am advised to write a bash command-file that would periodically switch the entry in ConstVolt_0flow/system/Air/fvScheme from: ...
10 votes
5 answers
21k views

How do I use $SECONDS inside a bash script?

I want to save the result of the $SECONDS command into a variable, to print time in format HH:MM:SS. This is what I've tried so far. I tried to print it in different ways and was always getting the ...
0 votes
1 answer
7k views

how to change value in json with jq when path to key is only reachable through select()

Let's start with an example output: { "title": "The Flash (2014)", "alternateTitles": [ { "title": "The Flash", "seasonNumber&...
1 vote
1 answer
90 views

Linux directory gets random name each time mounted

I have two hard-disks each with Ubuntu, when I access the second hard-disk while being in the first one, the directory has long serial-like name, which does not allow for a quick cd alias. Which ...
0 votes
0 answers
49 views

Hi can someone provide me a solution for soft link removal?

sudo ln -s /home/user/Downloads/msms/msms.x86_64Linux2.2.6.1 /usr/local/bin/msms I created a wrong softlink in the afore mentioned script which I need to remove. Can someone please provide a suitable ...
0 votes
0 answers
172 views

How to change my desktop background via bash?

I am trying to set up this script to change my desktop background, but gsettings set org.gnome.desktop.background picture-uri "file://$WALLPAPER_PATH" is not working. There is no error ...
0 votes
1 answer
4k views

Opening google-chrome from commandline with a specific window size

When I run the following command: nohup google-chrome-stable --incognito --window-size="770,570" index.html /dev/null & it works when there is no chrome window opened already. Otherwise it opens ...
2 votes
1 answer
8k views

Setting path permanently for openmpi in ubuntu

Every new instance of terminal forces me to export openmpi path before using it. I tried setting the path permanently using echo export PATH="$PATH:/home/$USER/.openmpi/bin" >> /home/$USER/....
0 votes
0 answers
58 views

How to autostart a jar file with swing GUI when booting Ubuntu

I'm trying to autostart a jar file with an .sh script: #!/bin/bash export DISPLAY=:0 java -jar /home/username/Desktop/jarfile.jar The jar file is a Swing GUI application. When i manually start the ...
0 votes
1 answer
77 views

automating keyboard key press 9 times if alt key was pressed

I want to make an automation strategy, if I pressed the Alt key with any other key, it will simulate the keyboard key press 9 times for that key. For example, I press Alt + q, it will simulate ...
1 vote
1 answer
172 views

What are the implications of using PROMPT_COMMAND like this?

I would like to insert the return code of the last command in reverse red color and inside brackets ([]) plus a colon (:) just before the bash (PS1) prompt. But, only if the return code is non-zero, i....
1 vote
2 answers
1k views

Canon MP210 printer: cannot install driver on Ubuntu 20.04

I have tried to add a printer in CUPS, however, there were no Canon MP210 drivers. The manufacturer does not provide any LINUX drivers. Also, I tried this on bash: (base)###:~$ sudo add-apt-...
1 vote
2 answers
167 views

How do I set up the Bash shell to automatically line change after entering a command?

I could use that in zsh for automatically line change after entering a command, but I don't know how to do that in bash. build_prompt() {df enter code hereRETVAL=$? prompt_status ...
0 votes
2 answers
59 views

Retain file extension in a simple while loop (one line)

I have a simple string that will rename all jpeg files in a folder sequentially: ls -v | cat -n | while read n f; do mv -n "$f" "pic-$n.jpg"; done But I have a folder with many ...
0 votes
1 answer
6k views

call bash script with array of strings with spaces as argument

I am fairly new to bash. I want to call a script located on a remote linux machine, passing some normal arguments and one array. The array contains string elements which may have spaces. I wrote a ...
7 votes
1 answer
2k views

Different behaviour of bash script in udev

I created a small sample-script which is reduced version of my real script and it looks basically as follows: #!/bin/bash echo "start" > /home/myName/log.txt #get list with all attached ...
-3 votes
1 answer
83 views

Bash Script, Automated no and yes [duplicate]

I need to have a script that instructs the system to run an fsck on a drive but I only want it to run if the drive is not mounted "/dev/mmcblk0p2 /mnt/Share ext4 defaults 0 2" Basically is ...
1 vote
1 answer
354 views

How to open a file from bash in another workspace

I am working on a project where a text file and tif file should be opened to full window to compare with each other. So easiest way to do this is to open either one in another workspace. That means I ...
5 votes
3 answers
5k views

Remove brew completely from my system

I interrupted the execution of homebrew while installing. Consequently, I ran into a problem mentioned here Error found when loading /home/user/.profile:. I had to comment eval statements in the ...
0 votes
0 answers
359 views

SyntaxError: Missing parentheses in call to 'print', while trying to run system

I am trying to run my system (Empire PowerShell), but it keeps giving me a syntax error. The system I used didn't support python3, so I had to install python2 which ended up working. But when I try to ...
0 votes
1 answer
239 views

command not found: shopt ON WSL Ubuntu 22.04

I inserted couple of env. variables such as: export WOS_MONGODB_URI='mongodb://localhost:27017/...' export WOS_AWS_REGION='us-east-2' export WOS_AWS_ENV='dev23' export WOS_SEED_MODE='test' export ...
2 votes
1 answer
308 views

"notify-send" not running with "rclone" ( when used in a startup script )

I'm trying to run the following script at startup. I am able to see the notification only when I execute the script from the terminal, or when I run it as a program. So the issue is basically when run ...
0 votes
0 answers
46 views

I need to run a program, as sudo, on boot, in screen... Tried a few things but can't get it all to work

My goals are: I have "myprogram" that needs to be run in sudo I want to run it as a service at boot I want it to run inside screen so I can monitor it So I can do 1&2 just fine, but ...
0 votes
0 answers
115 views

I need to run a script during first boot and want the CLI to open for possible input

Edit: I need a bit more explaining here. This is a one time only run personalization script for the computers that I have set up that I would like to run only on the first boot. After tweaking the ...
0 votes
1 answer
5k views

Problem setting up Environment for 'make' command execution

I am trying to set up devkitPro for ARM use, but I continuously get an error while executing the last two commands. The commands are make and make install. The tutorials I am following: http://...
131 votes
4 answers
223k views

Calculating the number of lines in a file?

How would I calculate and display the number of lines and words that are contained in a .sh file?
4 votes
1 answer
455 views

Multiple packages installation using bash

As we all know, the command we use in order to install multiple packages is: apt install package1 package2 package3` Using the following method in a Bash script: packages="package1 package2 ...
0 votes
1 answer
229 views

Why does my powershell script run with "pwsh" but doesn't with "sudo pwsh"?

I'm still somewhat new to Ubuntu / Linux so please bear with me if I'm not using correct terminology. I'm on Ubuntu 20.04 but I use Putty to perform everything via the terminal. I'm using a collection ...
5 votes
1 answer
5k views

Cursor positioning using mouse in bash possible?

In Vim I can actually position the cursor in insert-mode using the mouse. So I assume this should (technically) also be enable-able for the bash. Is it possible? This would be quite useful at times ...
3 votes
3 answers
19k views

How to use Bash Script to open URLs in a different profile with Firefox?

Working on a script to automate some tasks in Firefox. These tasks should run through a clean Firefox profile, so they are fast and don't interfere with any of my regular surfing. #!/bin/bash # ...
1 vote
2 answers
243 views

How to make script work to set IP address of ethernet adapter?

On Ubuntu 22.04 I have the following script #!/bin/bash INTERFACE="enx00e04c681730" echo "Interface: $INTERFACE set to IP $1" ifconfig $INTERFACE down ifconfig $INTERFACE $1 ...
10 votes
4 answers
5k views

Command to determine whether a fullscreen application is running?

I have a small shell script that plays a little jingle and displays a notification whenever I get a new email. The problem is that this shell script can get invoked anytime - including when I'm ...
2 votes
2 answers
500 views

How to move a set of files named as numbers in ascending order to another directory?

I have files inside a directory that are named as 00001.npy, 00002.npy, ..., 00150.npy, etc. The file names are increasing in ascending order. I want to move all files whose name is between 00008.npy ...
0 votes
0 answers
948 views

How to reload .bashrc settings without logging out and back in again?

I created a script that add's the below commands to the .bashrc file. The purpose is I need to store the commands entered by the user into the .bash_history. The below commands are adding to .bashrc ...
76 votes
4 answers
113k views

`apt-get` autocompletion of package name is broken

At some moment, the apt-get install autocomplete was broken. It was very useful to me to see the names of packages available for installation when pressing Tab. For example, if I would press the Tab ...
1 vote
0 answers
286 views

Changing LS_COLORS in Ubuntu 22.04 works in terminal but not permanently in .bashrc

I am learning linux thoroughly, I have downloaded my first VM with vmware-fusion on my mac m1. I have tried many times to update the .bashrc file but the one thing that is not changing for some reason ...
3 votes
1 answer
7k views

How to run multiple commands in multiple terminals using single shell script command

I have tried to write a shell script to run multiple commands in multiple terminals, but I am not able to run the commands. I can only open multiple terminals. This is written in a shell script file ...
0 votes
1 answer
135 views

How to make my script that has a timer to shutdown my machine work?

I have script to shutdown my computer after 2 minutes, and 1 minute before shutdown it sends a notification that says "It will shutdown after 1 minute". The script will be executed on click ...
0 votes
1 answer
9k views

How I will check that the mongodb service is runing or not using terminal command?

I'm using mongodb database to save my application data into collection but by some reasons the mongodb connection is break and there is lot of problems occurs and I want to check the mongodb ...
2 votes
1 answer
6k views

How to change the default directory that WSL Ubuntu terminal (on Windows 10) opens with

I installed the WSL Bash on Windows 10 so it can act as my terminal in VScode, but the default directory is ~/home/USERNAME I would like it to be /mnt/c/Users/USERNAME (so on my windows domain side) I'...
0 votes
2 answers
75 views

Issue with touch -t command when setting specific dates

I'm encountering an issue when using the touch -t command in the terminal. My goal is to adjust the access and modification dates of a file named "testShell00" to a specific date in the ...
-3 votes
1 answer
120 views

I would like to have an echo in 1 line for my ASCII art but I can't manage. PLS Help [closed]

I would like to have an echo in 1 single line for my ASCII art but I can't manage. PLS Help link to my ASCII: https://ascii-generator.site/r/Mor3V1/ PLS Help it is urgent
0 votes
3 answers
4k views

How can i move multiple files to folder with same name

I have multiple files like this: round3-bcF_01_bcR_01.R1.fastq round3-bcF_01_bcR_01.R2.fastq round4-bcF_01_bcR_01.R1.fastq round4-bcF_01_bcR_01.R2.fastq round3-bcF_01_bcR_02.R1.fastq round3-...
0 votes
1 answer
227 views

xterm: Xt error: Can't open display: :0

I have a cronjob that didn't work this morning. The line in crontab -e looks like this: 20 9 * * 1-5 export DISPLAY=:0 && /bin/bash /opt/ibc/twsstart.sh I couldn't find any errors in /var/log/...