Questions tagged [shell]

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.

817 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
1answer
670 views

Is it possible to send data to the the shell of another pseudo-terminal?

This image shows how pseudo-terminals work: If I have two terminal emulators open, I can send the string "Hello" from the first terminal emulator to the second terminal emulator: echo "Hello" > /...
6
votes
1answer
471 views

autocomplete filenames with underscores

What do I need to add to my ~/.bashrc so that if, for example, there is a file named name_separated_by_under_score, I can press n-s-b-u-s and then [TAB] and the shell will auto-complete the file name? ...
5
votes
2answers
158 views

Understanding fmt (gnu coreutils)

I'm using fmt (GNU coreutils) 8.25 and I fail to understand how to use it. In particular, I don't understand the following results. $ echo -n "a b c d e" | fmt -w3 -g3 I expected to obtain a b c d ...
5
votes
1answer
632 views

Sending SIGINT to process groups sometimes gets ignored

I start a process group from bash. Then I send SIGINT to the entire process group. Sometimes the SIGINT kills the processes, sometimes does not. Why does SIGINT sometimes gets ignored ? I see ...
5
votes
1answer
121 views

Is it possible to drop all write privileges in a shell for the current user

This is NOT for security purposes. Suppose I wanted to execute a shell script and, on a best effort basis, assume it left no side effects aside from things like auditd logging, avc reports, syslog, ...
5
votes
0answers
5k views

Detach a process from Sh (not Bash) or “disown” for Sh (not Bash)

Consider a shell script executed by Sh, not Bash (and I can't change it, and can't use a shebang, it's ignored). The & operator works, but disown $! does not and makes Sh complains “disown: not ...
5
votes
1answer
861 views

Pass login messages to tmux

When I login, I connect to a tmux session (either by exec'ing tmux if there is no current session, or exec'ing tmux attach if there is). However this means I don't see the login messages (/etc/issue, /...
4
votes
1answer
167 views

gunzip on Embedded machine

I'm using BusyBox 1.24.1 on my Embedded Linux machine (with kernel v3.10.31) and I get behavior I can't understand when unzipping files.  The gunzip command (often, but not always) fails, with no ...
4
votes
0answers
98 views

FreeBSD sh: is it possible to import a list of commands into fc without executing them?

I cannot find any indication that sh supports persistent history. So I am trying to create this functionality manually. At the end of my .shrc history I have added this: trap -- 'fc -ln -- 1 >> ...
4
votes
0answers
2k views

Gain root access without using root's login shell

I bricked the login of my root user by removing zsh while it was still the default shell. Now as a result will login in fail, since on login will it try to use /bin/zsh(1), which is missing. Only one ...
4
votes
1answer
1k views

Running scripts/commands from a host system in a chroot environment.

First of all, I have inside an android Operating System a chroot environment created using Linux Deploy. I am able to access it from Android using a terminal emulator and root permission. I would like ...
4
votes
1answer
301 views

Switching between two framebuffer programs

I have two programs (mplayer and a custom java application) which both present GUI using framebuffers. They run in separate processes. I want to be able to switch from one program to the other without ...
4
votes
0answers
888 views

convert windows path to unix path inside wine application command line

I'm running a windows application in wine, which executes configurable commands to run external applications (e.g. an diff editor to show differences between two source files). So these commands are ...
4
votes
1answer
1k views

Run git pull from a shell start-up script

I have Raspberry Pi that loads a shell script on start up. This script runs a python script, boot_camera.py, which is found in a repository. I Have a server which sends the Raspberry Pi a command ...
4
votes
1answer
1k views

KSH styling text based menu using STDERR

Is it possible to format the STDERR in order to have a better looking menu using the select command? I have a simple select select oChoice in $(<tempMenu.menu) ; do case "$oChoice" in ...
4
votes
2answers
1k views

Bash shell launched by forkpty() spawns child processes that ignore SIGINT. Why and how do I ensure SIGINT is not ignored?

I have a C program that uses forkpty to execute a bash shell. I'm finding that the programs launched by this shell are launched with SIGINT ignored, so when I send a Ctrl-C to the shell they never ...
3
votes
0answers
30 views

Should I set the locale to `C` when matching a range of numbers?

If I wanted to search for lines in a file that contain a or b or c or d I would run LC_COLLATE=C grep -E '[a-d]' file_to_search or LC_ALL=C grep -E '[a-d]' file_to_search If I fail to set the ...
3
votes
0answers
26 views

Tracing environment variable modification

Pesky $PATH, there's one item I used to use ~/.workspace/bin. I just can't figure where its coming from. I changed the user shell to /bin/sh, and logged in from tty, checked PATH, and it was clear of ...
3
votes
1answer
3k views

All TLS requests giving Peer's certificate issuer has been marked as not trusted by the user

When I try an https request to google.com, I just recently started seeing [root@ip-172-31-47-76 ~]# curl -I -v https://google.com * Rebuilt URL to: https://google.com/ * Trying 216.58.193.78... * ...
3
votes
0answers
92 views

Is there any utility that can drop me into a Intel ME Minix shell?

I see a lot of talk about Intel -3 ring mode running Minix. Is there any easy C program I can compile, or utility I can run that will drop me into a -3 ring mode Minix shell?
3
votes
1answer
733 views

Trap does not catch SIGTERM in child script

I have two scripts. First one is basically wrapper that calls subscript and sets timeout. #!/bin/bash # wrapper_script timeout --signal=SIGTERM 50 main_script.sh And if execution of main_script.sh ...
3
votes
1answer
256 views

Signal not received by script run using sh -c

I have a script which sleeps for 3 minutes before running a time consuming command. I want the script to exit if it receives SIGINT only while it is sleeping, and not when it is executing the long ...
3
votes
0answers
333 views

Control characters in a terminal with an active foreground process

Say I have a process running in a terminal in the foreground. While it is active I can type commands, hit return, and those will be executed once the process is done. Now say furthermore I would like ...
3
votes
1answer
91 views

New (login) shells (window) opens at $HOME rather than $PWD (like they used to) on macOS. What gives?

Every time I open a new shell window, I'm brought to my home directory rather than the current directory I was in when I gave the command to open a new Terminal.app window. I am under the impression ...
3
votes
2answers
2k views

How to display commands executed via ssh and their user's IP?

I asked a question before, but I didn't get a satisfying answer in : How can I display ssh commands executed from another machine? so I'll ask this time precisely. How to display commands and their ...
3
votes
2answers
300 views

Is there a a shell extension which is like scm_breeze where the output is numbered and you can alias to a file by its number

In scm_breeze, output is numbered and you can use the numbers in subsequent commands. For example here I am doing git status to see the changed files and then staging the first file for commit: ...
3
votes
1answer
1k views

Switch to local session from remote SSH

Say I start a process from the local shell - keyboard, mouse, monitor connected directly to actual physical computer... I then go to a second computer and SSH into the first computer. Can I switch ...
3
votes
1answer
1k views

mv file/folder with blank-spaces in its name doesn't work - LFTP

I have 2 spaces: My Synology NAS. And my FTP. If we assume that some files on my local NAS are also in my FTP repository, I want to move some files on my local NAS AND on my FTP on different folders. ...
3
votes
1answer
56 views

zsh fail to keep unquoted `$*` and `$@` equal

All shells tested do the same for the (quoted) pair "$*" and "$@" with this code: c='set a b @ c; IFS=:,@ ; a=$(printf "<%s> " "$*"); b=$(printf "<%s> " "$@"); printf "%-20s and %-20s\n" "...
3
votes
0answers
589 views

Umask value isn't reflected after making changes

I changed umask from 002 to 007 in /etc/bashrc and in /etc/profile. After logging as a normal user I run umask, and it displays 0027. It should display 0007, but it doesn't. What should I do? if [ $...
3
votes
1answer
63 views

Is there a version of the 'find' command that saves its state?

If a find is searching a large disc, and is aborted for some reason, I'd like to be able to start it again, from where it left off. Is there a version of 'find' that does this? The problem is that, ...
3
votes
1answer
2k views

How to kill inactive user logins on Solaris?

On a Solaris 10 server if i do a w, I get this: 12:26pm up 85 day(s), 1:13, 6 users, load average: 0.38, 0.36, 0.38 User tty login@ idle JCPU PCPU what blah pts/1 ...
3
votes
1answer
436 views

Secure share in samba not working, why?

The secure share that I created in samba with a password doesn't seem to work. I have the following on my /etc/samba/smb.conf on a Linux Mint box(3.13.0-37-generic) box. [myshare] ...
3
votes
0answers
1k views

Where EOF character is processed when it sent over telnet connection

Let's suppose I am connecting to telnet server, where bash is running. I am executing command cat > /tmp/qqq; typing some contents of a file and finally sending 0x0a 0x04 which meant EOF. The ...
3
votes
1answer
601 views

Generate SFV file, optimizing hard links

I'm currently running cfv -C -rr to generate a SFV file that contains the CRC32 checksums of all files in all subdirectories. The issue is that because there are so many hardlinks, this process is ...
3
votes
0answers
577 views

Higher-level wrapper for entr or inotifywait

I'm looking for a way to rerun a specific command as soon as any of the files in a subdirectory (perhaps minus selected excludes) changes. Use case I'm working on a project that is self-contained in ...
3
votes
0answers
1k views

Read output in `screen` from outside

Suppose I opened up a screen to run some program that outouts some result. Once the program finishes, is there a way to get the result in the screen from outside. For example: I opened up a screen ...
3
votes
1answer
2k views

Run vsim from dmenu — it only works when directly invoked in the terminal

Works: vsim, sh -c vsim Doesn't work: echo "vsim" | sh, echo "vsim" | xargs -I {} sh -c "{}" I want to run ModelSim (vsim) with dmenu, which is triggered using xbindkeys. Details vsim is a ...
3
votes
1answer
1k views

set tab color in a tabbed terminal emulator

I would like to set in my terminal emulator (i.e. gnome-terminal) the color of the tabs like in the osx's terminal emulator. Is there this feature in any of the linux terminal emulator plethora? EDIT:...
3
votes
0answers
1k views

gnome-terminal cmd leaving processes open after closing parent window

The following simple command should demonstrate my issue: gnome-terminal --tab -t "Tab 1" -e "/bin/bash" --tab -t "Tab 2" -e "/bin/bash" This should open a new window with two tabs and an active ...
2
votes
0answers
25 views

bash: pass each command through time command (to measure execution time)

How to pass each command (typed in the shell) through time command? Reason of the question: need to measure execution time of each command (without typing time each time). Example (wanted behavior): ...
2
votes
1answer
51 views

Can I run the command in specific terminal?

OS: Linux mint 19.2 Cinnamon SHELL: Zsh TERMINAL: Tilix I want to create a shell script. which have 2 steps. Open the new terminal. Run source bin/activate at terminal that I opened. How do I run ...
2
votes
1answer
31 views

Temporary display full name of argument instead of short name/abbrev

After an command, where the user should give an output location with -o, I wondered if there is an (standard) command that temporary displays the full name of the given argument, like the -o, that ...
2
votes
0answers
126 views

nmcli: How to escape comma and other characters for shell script

At first I imported an .ovpn file. But I want to add the username and the password. So i thought to use nmcli modify is the best soultion, or? PASSWORD="pass,word" nmcli con modify vpn_connection vpn....
2
votes
0answers
34 views

Backup Script with Lock giving Invalid Syntax Error

I'm setting up a simple backup script to backup key files on my server every 12 hours. Just trying to test the script now and I'm getting the following error message; python /<pathwayhere>/...
2
votes
0answers
33 views

Update all installed GNOME 3 extensions at once

I use extensions.gnome.org website and GNOME Shell integration Chrome extension to search and install gnome-shell extensions. I know that I can use the website and the Chrome extension above to also ...
2
votes
0answers
37 views

Key binding to swap shell foreground/background jobs

In spite of heavy tmux use and switching between panes, I still frequently find myself using shell job control. When something needs poking I'll background the tool I'm using with Ctrl+Z, poke the ...
2
votes
1answer
66 views

Restart shell script if not printing

I have a shell script that just calls a Python file in loop e.g.: for i in $(seq $start_index $end_index) do python my_script.py done The Python process halts when it is not able to generate ...
2
votes
0answers
329 views

Python open screen and execute inside screen

I have a py script S1 that I would need to execute inside a screen. On an end-user point of view, I would like them to just execute another python script S2, which will open a screen and execute the ...
2
votes
0answers
21 views

Shell: short version of `<application> & disown; exit` for replacing the terminal with a gui application

On a tiling window manager starting a gui application from the terminal emulator leaves the terminal open alongside the newly started window. A solution for this is $ <application> & ...

1
2 3 4 5
17