Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
1 vote
1 answer
30 views

SSH from A through B to C, using private key on B

Schematic: ssh ssh A ------> B ------> C ^ ^ using A's using B's ssh key ssh key Preconditions: A is running ssh-agent A can access B B can access C A can't ...
J.Nexus's user avatar
  • 11
0 votes
1 answer
24 views

How to detect even or odd minutes in bash script

I need to detect whether the current minutes are even or odd regardless of the time zone ! I tried this according to answers from several sites: #!/bin/bash n=$(date +"%M") r=`expr$n%2` if [...
freetoair's user avatar
1 vote
0 answers
23 views

How to Identify and Terminate Idle tmux Sessions on a Debian Server

I have a Debian server with multiple tmux sessions running. Some of these sessions are idle and not running any active processes. How can I identify and terminate all tmux sessions that are not ...
maxime de smedt's user avatar
2 votes
1 answer
58 views

Provide argument while starting a service using systemctl

I have a service installed on an old server and it is started using; service load-simulator start medium The value medium acts as a profile of sorts. It can have values like low, medium, high, and ...
Rajkishan Swami's user avatar
3 votes
2 answers
426 views

bash see if element inside array is inside a different array

I am trying to test to see if an element inside an array exists. A test case is array1=(a b c) array2=(c d e) for ((i=0; i < ${#array1[@]}; i++)); do if [[ ${array1[$i]} == "...
Abbatrombone's user avatar
0 votes
1 answer
18 views

Font size issue with xterms started through icewm's hotkeys

Recently got a new laptop with 1920x1080 monitor instead of 1366x768 on old laptop. All my many xterms suddenly smaller and text illegible. After investigation, decided easiest solution was an alias ...
user985675's user avatar
0 votes
1 answer
25 views

Dealing with whitespaces in file names after git grep -l

I'm trying to run the script below and I'm struggling with pathspec error when the filename has whitespaces. I have already read some other posts around here, but since I am not an expert I was not ...
O Pardal's user avatar
  • 103
1 vote
1 answer
66 views

How to merge all mp3 files located in the same directory?

The command below used to work but stopped around ubuntu/kubuntu 20.04. ls *.mp3 | sed -e "s/\(.*\)/file '\1'/" | ffmpeg -protocol_whitelist 'file,pipe' -f concat -i - -c copy output.mp3 ...
Cortez's user avatar
  • 11
0 votes
0 answers
27 views

Grep’s result coloring, and right-to-left scripts

I have a text file with a single line that contains the single Yiddish word azoy, in Hebrew script: אַזױ. Then I grep for occurrences of the oy character, ױ. (This is highly simplified of course, in ...
Ruud Harmsen's user avatar
1 vote
0 answers
62 views

How to confirm ready state for an external USB disk before attempting other actions

[start of edit 1] Before I plug in my external USB backup drive, my computer is fully booted-up, and I am in my session as root. Because of its location, my USB cord is already plugged in, but I ...
Eric Marceau's user avatar
0 votes
1 answer
24 views

changing the directory a tarball decompresses to

When I do wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz and then tar xvzf install-tl-unx.tar.gz the files get extracted (right now) to install-tl-20240521. On the CLI it's ...
neubert's user avatar
  • 7,204
1 vote
1 answer
168 views

How to find matching yaml files based on content

I have a bunch of files that contain yaml. Some files are yaml-only, some have yaml front-matter. I would like to be able to query the list of files to return a list that match certain criteria. In ...
user2567544's user avatar
0 votes
1 answer
112 views

ls -ltr on the terminal lists the files but says "No such file or directory" in a shell script

I am new to Bash and am practicing some shell scripts. I wanted to write a script to list all the folders and their file count, if a root path is passed as a parameter value from the terminal. The ...
MNIA's user avatar
  • 1
0 votes
2 answers
79 views

File with no permission accessed with sudo

as no user have any permission to read file.txt,then why/how 'sudo cat file.txt' prints file contents? bs01316@bs01316:~/test$ ls -l total 4 ---------- 1 bs01316 bs01316 6 মে 7 16:20 file.txt ...
yolin00's user avatar
  • 101
0 votes
1 answer
68 views

How to do a Proximity text search, 2 + words?

What is a Linux terminal command to do a Proximity text search? Search a directory, recursively, for files that contain : 2 words or more within 99 characters of each other any order of above words. ...
joseph22's user avatar
  • 367
0 votes
1 answer
57 views

Why executing 'bash' in the terminal opens wsl on Windows 10?

When I run the 'bash' command in the terminal, my console automatically switches to the 'wsl' mode. Why is this happening and how do I stop this behavior? It causes problems when I run other scripts, ...
Andrii Hnatushchenko's user avatar
17 votes
2 answers
4k views

How does ls know how to output its results?

While creating a bash script, I found that this code ls puts all files on one line: pi@raspberrypi:~/ptlrestinterface$ ls update.sh web.config MyApp.runtimeconfig.json still ls | head -n1 ...
Bart Friederichs's user avatar
0 votes
0 answers
24 views

How can I execute a command whenever I change the PowerDevil power profile?

I have a laptop with a variable refresh rate (up to 120Hz) monitor. I want to change the refresh rate to 60 whenever I switch the power profile to "Power Save" in Powerdevil, and change it ...
StrongSand94191's user avatar
1 vote
1 answer
328 views

Complete overview of Bash and Zsh startup files sourcing order

I was confused in what order my shells source which files. When researching this for myself, I came across several sources online and even read some parts of the manuals for both shells. But still, ...
Silas's user avatar
  • 39
0 votes
1 answer
33 views

sed does not consume rest of the line

I have one line of different words stored in a txt file N/A 9.0 Yes Yes N/A N/A N/A N/A 8.8 Yes Yes N/A N/A N/A N/A 8.7 Yes Yes N/A N/A N/A N/A 9.2 Yes Yes Yes Yes Yes Yes 9.1 Yes Yes Yes Yes Yes Yes ...
Cobra Kai Dojo's user avatar
0 votes
1 answer
129 views

Linux Bash Wait Command Not Working

I am trying to use and bash file .sh to start other bash files in seperate terminals. I want them to run one after the other as I use them to copy large numbers of files to the same Hard Drive. ...
Dave's user avatar
  • 1
0 votes
0 answers
32 views

Unknown terminal: "/tmpERM"

On my Linux headless distro, i have a recurring error where when running some commands ("clear", "nvim", etc.), instead of the expected behaviour of running the command i get an ...
lo9ud's user avatar
  • 1
0 votes
0 answers
30 views

Is there any way to create a new window terminal (pseudo-terminal) using a command without setting env $DISPLAY?

I am currently building an open-source utility (plugin), which requires a new terminal window (pseudo-terminal) to become more effective whenever it gets executed. I was using gnome-terminal to ...
zenitsu's user avatar
1 vote
0 answers
21 views

How to calculate GUI used memory widget value?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' GUI = Graphical User Interface GUI used memory = see widget image below. . 2nd method to display used memeory = 2211 MB =...
joseph22's user avatar
  • 367
1 vote
0 answers
95 views

How to automatically reconnect to WiFi when 'limited' connectivity occurs?

I'm experiencing an issue with my school's WiFi where it stops working every 5 minutes or so. When this happens, nmcli monitor shows "Connectivity is now 'limited'". I have this short script ...
Alexandre Ramos's user avatar
2 votes
1 answer
108 views

tmux doesn't instantly update pane's title

I'd like to have tmux "instantly" update the pane's title to match what is currently being executed in the terminal. For an instance: If the pane contains the shell then its title should be ...
pic810's user avatar
  • 21
0 votes
0 answers
41 views

How to match PDF okular colors with Terminal colors?

OS: Kubuntu 22.04.4 LTS x86_64 okular 21.12.3 konsole 21.12.3 to display above: neofetch --stdout |grep 'OS:' okular -version konsole -version outputs: ok match color Blue in Terminal with ...
joseph22's user avatar
  • 367
1 vote
0 answers
66 views

How to let root use sudoedit as if it was a user?

I'm writing a wrapper for myself around vim that detects when the user's trying to edit a file that doesn't belong to them, and suggests sudoedit or visudo instead. I want to use sudoedit rather than ...
aaaalz's user avatar
  • 11
1 vote
1 answer
243 views

TO close Tmux along with terminal (if terminal is closed)

I have configured my Tmux to open with i open terminal by modifying the .zshrc file. [[ -z "$TMUX" ]] && tmux -u It worked fine, now I want to close the tmux session when I close ...
shohel hossain's user avatar
0 votes
1 answer
655 views

How can I reset my MySQL root password in MySQL 8.0.36 on Red Hat 8 if ‘mysqld_safe’ is gone?

For years I have been using mysqld_safe (like this) with --skip-grant-tables so I can safely reset my MySQL root password: sudo mysqld_safe --skip-grant-tables & But recently, while attempting ...
Giacomo1968's user avatar
1 vote
0 answers
56 views

How to detox filenames in a bash script with no errors posted?

OS: Kubuntu 22.04.4 LTS x86_64 detox 1.4.5 To display above: neofetch --stdout |grep 'OS:' detox -V Here is a toxic filename, starts with s1: s1 Ä Ö Ü - ä ö ü Science & < > " 1 \ 2 ⁄ 3 ...
joseph22's user avatar
  • 367
0 votes
0 answers
82 views

How to launch another blank terminal in Kali Linux?

When I launch another terminal in Kali Linux with Cmd+Shift+T, I can see Shell No. 2 tab created. However, it is just a copy of Shell No. 1 and all the commands I ran on Shell No. 1 are visible on ...
kerblue's user avatar
-1 votes
1 answer
74 views

Search and replace doesn't work with sed busybox. getting sed: unmatched '/' error

I am trying to search a particular string and replace all occurrences within a file. sed -i -e "s/$search_string/$replace_string/g" $filePath I keep getting sed: unmatched '/'error on ...
aelor's user avatar
  • 99
1 vote
2 answers
114 views

How to detect if “/dev/mapper/dev0” exists in Bash?

I'm trying to make a decryption software for my NAS, so that it automatically mounts all drives and decrypts them. But, I need to know if the sudo cryptsetup luksOpen /dev/blahblahblah dev0 exists ...
Novum Gain's user avatar
0 votes
1 answer
86 views

Changed color settings of ble.sh bash terminal are not applied

I installed the ble.sh from this git repository https://github.com/akinomyoga/ble.sh.git, but i want to customize the color settings with ble-face commands. What happens is that, I changed the color ...
Vitor Martins's user avatar
10 votes
4 answers
2k views

Why does assigning a variable with command substitution, and then echoing that variable, always fail?

Why does the following not work in Bash? # Ensure TEST is unset export TEST='' echo "Hello world!" > test.txt && TEST="$(cat test.txt)" echo "$TEST" It always ...
Rob's user avatar
  • 103
1 vote
1 answer
97 views

Keep command line visible while scrolling

Unsure what the best place to tackle this would be .bashrc? Using different shell? Some fancy terminal emulator? Basically, I just want to keep seeing the command line / the last line of the terminal ...
sonofevil's user avatar
  • 127
0 votes
2 answers
226 views

Remove all files with name starting with single quote

I need to delete all files with these names (the quotes are part of the name): 'index.html?some-query-string' I tried with: rm \'index.html?*\' I get this error: rm: cannot remove ''\''index.html?*'...
Giacomo M's user avatar
  • 143
0 votes
0 answers
201 views

how to use curl for single sign-on website or page

I've already written a shell script but it's not working. I'm getting an empty response whereas it should first return a token and also it should login then register the API. That's the task which my ...
DevOPs's user avatar
  • 1
0 votes
1 answer
58 views

How to simply cleanup a filename?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' . How to simply cleanup a filename, not file contents? by removing from a filename: \n newlines \t tabs non printable ...
joseph22's user avatar
  • 367
0 votes
2 answers
233 views

Bash provide comma-separated list in multiple lines

I have a bash script that is suppose to run another program called file-selector. #!/bin/bash ... ./file-selector -exclude="a/b/c/d/e/f1,a/b/c/d/e/f2,a/b/c/d/e/f3,a/b/c/d/e/f4,a/b/c/d/e/f5,a/b/c/...
Subzero123's user avatar
0 votes
0 answers
67 views

docker compose down service with label

I'm trying to figure out how to programmatically compose down several services with a label. Currently I'm just using docker container stop as such: docker container stop -t 60 $(docker ps -q -f "...
Modem7's user avatar
  • 1
1 vote
1 answer
59 views

merge numbered files from different directories into same directory in correct order

I have some directories named FOO and BAR and etc. that have files in form FOO/ 1.png ... 18.png BAR/ 1.jpg ... 12.jpg ... and I would like them to be all copied into the DESTINATION directory ...
user3446323672's user avatar
1 vote
1 answer
77 views

What's a good way to encode a file name for caching a video thumbnail?

I'm writing a previewer script for lf using chafa to display preview images as sixels. I'm writing the part of the script for previewing videos, and decided to just display the first frame of the ...
revsuine's user avatar
0 votes
2 answers
46 views

An incorrect path is displayed in my custom command line prompt in bash

I would like to display the current and parent directories in my Linux command prompt. For example, if the current directory is /home/user/proj/src, I'd like the prompt to display proj/src. I found ...
Epsilon's user avatar
  • 103
0 votes
1 answer
89 views

Arch linux: How to exclude files from subfolder while using rsync for copying

I wanted to make a copy of files from one directory (folder "test2") to another directory (folder "Destination") while using rsync in linux console. The only problem? I want to ...
Minja Culic's user avatar
2 votes
0 answers
102 views

Why my terminal throws control characters while using arrows in mysql-client?

I have a situation with remote servers (all Debians) where I get control chars into mysql-client command line when I try to search in history (CTR+R) and try to make the first move: mysql> update ...
wk.'s user avatar
  • 188
0 votes
2 answers
488 views

How to output a bright Green check mark?

OS: Kubuntu 22.04.4 LTS x86_64 to display above: neofetch --stdout |grep 'OS:' Terminal or bash script: printf '\u274c\n' # works fine. Bright red X. ❌ printf '\u2714\n' # outputs a check mark, ...
joseph22's user avatar
  • 367
0 votes
1 answer
78 views

The last command output in linux for reboot is not giving the uptime instead it says still running twice

[root@localhost test]# last -x reboot -s -30days reboot system boot 5.14.0-325.el9.x Sun Mar 10 10:51 still running reboot system boot 5.14.0-325.el9.x Tue Mar 5 03:05 still running In the ...
AshKash's user avatar
1 vote
0 answers
29 views

How to make a script to launch different scripts in different workspaces in linux?

I have limited access to a linux machine, meaning I cannot install any external tools. I want to make a script to open terminals with ssh at different workspaces. However, I found that one way to move ...
Yi Qiang Ji's user avatar

1
2 3 4 5
99