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
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
Parameshwari's user avatar
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[...
reneas's user avatar
  • 191
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 ...
Jim Halpert's user avatar
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 ...
John-L_.'s user avatar
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 ...
Tms91's user avatar
  • 375
0 votes
0 answers
94 views

i get this error when trying to kill pulseaudio

$ pulseaudio -k E: [pulseaudio] main.c: Failed to kill daemon: No such process Is there any other way? I tried the pavucontrol fix but it didn't work.
N.T.N's user avatar
  • 1
8 votes
1 answer
1k views

How can I properly make a bash prompt with error colors and emoji?

After solving the first issue with my custom prompt I still have another one left. When I cycle through my last used commands via the arrow-up and arrow-down keys I will sometimes have some characters ...
reneas's user avatar
  • 191
0 votes
1 answer
61 views

How to hide command output, then run another command [duplicate]

I have this command which may output an error, so I hide it using &>/dev/null. Now I would like to run this command, then run another command. This is what I have now: ( aaa &>/dev/null )...
Z0q's user avatar
  • 125
1 vote
1 answer
134 views

changing bash output format results in strange behaviour

I already changed my bash output format to something like this: which I am very happy with. I achieved this by adding this code to the .bashrc: set_PS1() { local RESET=$(tput sgr0 ) local ...
reneas's user avatar
  • 191
1 vote
2 answers
63 views

How to hide desktop from Ubuntu Desktop Applications UI

I found the following link for changing file types application: https://superuser.com/questions/21626/ubuntu-change-the-default-program-used-to-open-a-type-of-file Here is the command for associating ...
stackbiz's user avatar
  • 267
0 votes
0 answers
20 views

Bash script for executing linux commands on remote machines using ssh key [duplicate]

I want to run a script to get details of hardwares and user details from multiple remote machines by login using ssh private key. this is my script #!/bin/bash # Check if the user provided a file if [...
Subash's user avatar
  • 66
1 vote
1 answer
125 views

Cannot run bash script Cisco Anyconnect. "Sorry, you need user privileges to run this script." When executing as root

For work i need to install Cisco Anyconnect and i can't get it to install due to a rights issue. I have everything set up, i think correctly. I'm following this instruction. After step 8 (executing ...
CJDG's user avatar
  • 13
4 votes
3 answers
627 views

Search for a "string" or "String with Spaces" recursively that may be a file- or directory-name or a text inside a file

I would like to search for the string rstudio (and its different possible combinations mentioned below) recursively starting from /. In some locations, rstudio is a string inside another file (but ...
koustav_ch's user avatar
0 votes
0 answers
96 views

VScode not opening on ubuntu 23.10

I tried running vscode but when I write code . in bash or open vscode via the icon, VScode doesn't want to open anymore for some reason, To be more specific the vscode windows do open, but none of ...
dsdfs's user avatar
  • 1
2 votes
1 answer
125 views

Cron not running script on boot

The main idea is to make my pc run a script on boot in wich x11docker takes care of lifting a container with a youtube video. this is mi crontab -e: @reboot /usr/local/sbin/script-exo.sh script im ...
ømen's user avatar
  • 21
0 votes
0 answers
116 views

AWK issue on Bash script

I need to shortlist the logs between the particular timestamps. I can achieve it by using the below command. awk '$a>="Feb 5 10:44:*" && $a<="Feb 5 10:54*"' /var/...
Arunkumar NKL's user avatar
0 votes
1 answer
39 views

CDPATH help documentation—3

man bash says: The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the same as ...
Guilherme Woolley's user avatar
4 votes
1 answer
545 views

Unzip to directory of the same name

I am trying to unzip files supplied by Google Takeout and need a command to unzip all zip files in a directory to a directory of the same name as the zip file to avoid conflicts. The zip names cannot ...
Datadimension's user avatar
-1 votes
1 answer
159 views

How do I use CDPATH to cd to Documents no matter which directory I am in?

If the cd shell builtin doesn't see the target directory in the current directory, it consults CDPATH. If the target directory is absolute (begins with the root directory, /), CDPATH is not used. ...
Guilherme Woolley's user avatar
0 votes
2 answers
116 views

How can I echo double quotes around text [duplicate]

How can I get the double quotes to show for 1 second and ready? echo -e " test.sh ""1 second"" "ready""
fixit7's user avatar
  • 3,127
4 votes
2 answers
421 views

Detect that the workspace has changed

I can change my current workspace in various ways, e.g. by clicking on some switcher widget, with some key combination, with a command in a terminal. Is there a way to detect that the workspace has ...
Rodrigo's user avatar
  • 143
4 votes
2 answers
789 views

Using grep to search for line that begins with a variable whose value is a dollar sign

I found a lot of very similar problems, but not exactly this. I have a text file with the following contents (no repeats, fixed 4 characters per line): A1234 G1234 $1234 M1234 I'm trying to use grep ...
Aylox's user avatar
  • 43
0 votes
2 answers
185 views

Setting DEBIAN_FRONTEND remotely

Is there any way to set DEBIAN_FRONTEND=noninteractive when executing a script remotely via SSH? Doing so I get this error: sudo: sorry, you are not allowed to set the following environment variables: ...
Socrates's user avatar
  • 2,493
1 vote
1 answer
152 views

Ubuntu 22 shell scripts on desktop open in text editor instead of launching

I have some shell scripts (files *.sh) on my Ubuntu desktop, eg. startdoublecmd.sh or startlazarus.sh. When using Ubuntu 20, those scripts started automatically upon double clicking on them. Now I ...
tk_'s user avatar
  • 121
1 vote
1 answer
76 views

Help command documentation explanation

Running help cd gives: The variable CDPATH defines the search path for the directory containing DIR. Alternative directory names in CDPATH are separated by a colon (:). A null directory name is the ...
Guilherme Woolley's user avatar
0 votes
2 answers
85 views

How to monitor particular command or add extra functions to it?

I am attempting to implement mobile push notifications (utilizing the Docker ntfy service) for scenarios such as automatic system updates and Timeshift snapshot creation. None of these commands are ...
zawier's user avatar
  • 13
0 votes
2 answers
296 views

cron unable to run .sh script - 22.04

I am trying to run a simple script that checks the battery percentage and shows it through a notification (notify-send). The script runs correctly if ran from terminal manually: ~/path-to-script/...
overmach's user avatar
0 votes
0 answers
61 views

Byobu doesn't source /etc/profile.d scripts

I'm using Ubuntu 20.04 and byobu. One of the scripts I have in /etc/profile.d will enable bash completion for kubectl and helm for all users. It works when the user logs in but not once they run ...
rje's user avatar
  • 1
2 votes
1 answer
440 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 $...
nocarea's user avatar
  • 23
-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: ...
user39178's user avatar
-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 ...
odavidcesar's user avatar
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 /...
Steflan's user avatar
  • 11
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 ...
Sambit Mandi's user avatar
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 ...
Daniel Tscherkaschin's user avatar
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 ...
Normal's user avatar
  • 123
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....
FedKad's user avatar
  • 10.5k
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 ...
Seongjun Lee's user avatar
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 ...
DealTime444's user avatar
-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 ...
Christopher Lock's user avatar
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 ...
ardu ros's user avatar
0 votes
0 answers
364 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 ...
Seul's user avatar
  • 1
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 ...
Sabat's user avatar
  • 1
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 ...
BuddyBoy's user avatar
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 ...
Anima94's user avatar
  • 23
4 votes
1 answer
457 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 ...
Stormlord's user avatar
  • 6,337
0 votes
1 answer
233 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 ...
tl6277's user avatar
  • 1
2 votes
2 answers
501 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 ...
sachin rawat's user avatar
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 ...
Damika's user avatar
  • 101
0 votes
0 answers
957 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 ...
SIVA KUMAR KALLURI's user avatar
1 vote
0 answers
288 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 ...
theMyth's user avatar
  • 111