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.

1,017 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
3answers
917 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
107 views

Does the "reboot" command log me out of the shell or does it forcefully terminate it?

Under Linux, if I issue a reboot command from the shell, what is the sequence of events that lead to the shell (e.g. bash) disconnecting? I think it's one of the following, but not sure which: It log ...
5
votes
2answers
214 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
1k 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
132 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
1answer
1k 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
0answers
162 views

Why does ZSH finish executing a function after exit was called from a trap?

Consider the following script: trap "echo TRAPPEDTERM >&2; exit" TERM termself () { kill -TERM $$ echo "Survived TERM!" } termself echo "Bye." Executed ...
4
votes
0answers
174 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 ...
4
votes
0answers
2k views

List all jobs in all shell sessions (not just the current shell), by current user

I know that the jobs command only shows jobs running in current shell session. Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for ...
4
votes
1answer
174 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
108 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
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... * ...
4
votes
1answer
2k 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
1k 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 ...
4
votes
1answer
365 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
1k 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
3k 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

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:...
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
50 views

force specific shell environment variable on process using /etc/pam.d/ rules

I am using slim login manager, and it has its own pam rules file: /etc/pam.d/slim. auth requisite pam_nologin.so auth required pam_env.so readenv=1 auth required pam_env....
3
votes
1answer
144 views

Why is ssh-add <(echo 'pk contents') not working?

I am getting this error: Permissions 0660 for '/dev/fd/63' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. when I run ...
3
votes
1answer
345 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 ...
3
votes
0answers
36 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
49 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
0answers
540 views

Manually restore saved session files on KDE using qdbus command

At times, i have multiple konsole terminal open with multiple tabs. I would like to save and restore it manually, just in case i accidentally close the window. In KDE there is a command to save the ...
3
votes
0answers
216 views

Source-able/executable shell script in the POSIX shell language

What's a good POSIX compliant way to make a script both executable (a function from the script gets executed) and in-sourcable with the . command (nothing happens except (at least) 1 function becomes ...
3
votes
0answers
271 views

Is there jitsi SIP-client for Ubuntu or Debian which has command-line interface?

Is there jitsi SIP-client for Ubuntu or Debian which has command-line interface? So, for example, I can make calls without using jitsi GUI, just sending commands to the application.
3
votes
0answers
128 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
0answers
2k views

Will a child process be in a different process group than the parent process?

I always thought that a child process will be in the same process group as the parent process. But I have read the following from here: if you run some_app from the shell, the shell creates a new ...
3
votes
0answers
2k views

Fastest way to recursively list all the files in a directory

I'm trying to get the relative path of all the files in a directory. It can run on hundreds of thousands of files so I need it to be fast. I've tried find . and rg --files (rg being ripgrep) and rg ...
3
votes
1answer
375 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
412 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
108 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
1answer
2k 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
0answers
684 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
68 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
3k views

Why is tmux starting slower and slower over time?

On my Ubuntu server I run tmux. When I login on the server itself I get tmux, when I login with SSH I get tmux too. Right after a reboot logging in on the server starts tmux within seconds and when ...
3
votes
1answer
515 views

"render" textfile with carriage returns (^M) and save output to file

I have a Python CLI program that runs for a long time and has a sort of progressbar, which basically prints some text in the loop without "\n" at the end, at the next iteration it prints "\r" to erase ...
3
votes
1answer
3k 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
531 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
779 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
680 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
1answer
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
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
43 views

System-wide ${PATH} for non-login shells (in Debian)

I saw that similar questions were already asked, but I think the problem still exists. I did a standard thing, added a software to the /opt/ directory. Say, Go. /opt/go is the main directory and /opt/...
2
votes
0answers
43 views

zsh completion: different completion when stdin is a pipe

I have a program foo. It can be used in 2 different modes: foo [-c] file1 [file2] or find . -print0 | foo [-0] [-c] In first mode, the only optional argument is -c, and then there are one or more ...
2
votes
0answers
41 views

Do I ever need to use a ./ in the beginning of a relative log file path or a data file path?

Say I am running some command and redirecting its output to a log file with relative path. Three different examples: sh script.sh > logs/script1.log ./script2.sh &> logs/script2.log ./...

1
2 3 4 5
21