date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,365,266,803,000 |
(1) For remote forwarding:
-R [bind_address:]port:host:hostport
Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side. This works by
allocating a socket to listen to port on the remote side, and whenever a connection is made to this... |
These sketches should help you answer all the questions: https://unix.stackexchange.com/a/118650/121504
But to answer your questions explicitly:
For remote forwarding:
port is a connection endpoint in the SSH server.
For local forwarding:
port is a connection endpoint in the SSH client process
For SOCKS proxy:
port... | Which processes do the ports (as communication connection endpoints) belong to in SSH port forwarding? |
1,465,385,311,000 |
if I want to count the lines of code, the trivial thing is
cat *.c *.h | wc -l
But what if I have several subdirectories?
|
The easiest way is to use the tool called cloc. Use it this way:
cloc .
That's it. :-)
| Counting lines of code? |
1,465,385,311,000 |
I suddenly decided I'd like to look at the source code for 'echo'
$ which echo
/usr/bin/echo
so
$ ls -al /usr/bin/echo
-rwxr-xr-x. 1 root root 32536 Oct 31 2016 /usr/bin/echo
so
$strings /usr/bin/echo
leads me to believe it's a compiled C program
Now I'm stuck.
How do I:
Find out which package it's in
Get the so... |
RHEL/Fedora
Run rpm -qf /path
$ rpm -qf /usr/bin/echo
coreutils-8.25-17.fc25.x86_64
Download the source package (use yum for RHEL):
$ dnf download coreutils --enablerepo="*source"
Extract the sources, patches from the SRPM package downloaded in current directory, change to the directory where the files are extracted... | How do I look at the source code for a command? [closed] |
1,465,385,311,000 |
I'm installing cmake from the cmake.org website and they provide two files that I believe are intended to verify the source code download cmake-3.11.0-rc3.tar.gz
On the same page, they have links to download a cmake-3.11.0-rc3-SHA-256.txt file and a cmake-3.11.0-rc3-SHA-256.txt.asc file
What I don't understand is:
Ho... |
Have a look inside the .asc file, you will see it starts with:
-----BEGIN PGP SIGNATURE-----
So this is a PGP Signature. It means it signs some content with some specific PGP key.
1) The content
Based on the name, the content is the file .txt, it is the list of files corresponding to the software to download and eac... | How does providing an asc file ensure I'm downloading the intended source code? |
1,465,385,311,000 |
According to this link, when changes to the Linux source code are submitted, they are reviewed by a hierarchy of maintainers, eventually concluding with Linus himself. How does one become such a maintainer?
(Context: I'm teaching a class about the basics of Linux and one of my students asked this, and I'm having trou... |
Taken literally, kernel maintainers are the people listed in the MAINTAINERS file. There are mainly two ways to get listed there: one is to add a subsystem to the kernel, and become its maintainer, the other is to take over maintainership for an existing kernel component. There was a recent example of the latter which... | How to become a Linux source code maintainer? |
1,465,385,311,000 |
I have some C source code which was originally developed on Windows. Now I want to work on it in Linux. There are tons of include directives that should be changed to Linux format, e.g:
#include "..\includes\common.h"
I am looking for a command-line to go through all .h and .c files, find the include directives and r... |
find + GNU sed solution:
find . -type f -name "*.[ch]" -exec sed -i '/^#include / s|\\|/|g' {} +
"*.[ch]" - wildcard to find files with extension .c or .h
-i: GNU sed extension to edit the files in-place without backup. FreeBSD/macOS sed have a similar extension where the syntax is -i '' instead.
/^#include / - on e... | Replacing backslashes with forward slash within double quotes |
1,465,385,311,000 |
Various minifier scripts exist for shell code, (e.g. bash-minifier), but how about the reverse?
Are there any shell-centric utils or scripts to automatically turn a one-liner like this:
echo foo;echo bar;echo "baz;bing";echo 'buz;bong'
...into this:
echo foo
echo bar
echo "baz;bing"
echo 'buz;bong'
Or turn minimali... |
Minification is not generally a reversible operation, as information could be lost in the process, e.g. consider human-readable variable names, comments, logical constructs, which can be written in multitude of different ways e.t.c.
But there are various tools, which can pretty-print or beautify your code,
which shoul... | Are there any unminify tools for shell scripting? |
1,465,385,311,000 |
I have a binary code and I want to run it.
01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100
How can I create a file "application/x-executable" and execute it on Debian?
|
That's just the binary representation of the ascii encoding of "Hello World", not an executable, there's no way to execute that.
| Execute binary code |
1,465,385,311,000 |
I'm working on a CentOS 7.9 GNU/Linux system. I've built and installed a newer version of git (2.34.1 instead of 1.8.3.1 that's bundled with the distribution) under /opt/git/2.34.1, with a symlink to that directory at /opt/git/current; and I've added that symlinked directory to (the beginning of) my $PATH variable.
Un... |
Git uses libcurl library to push/fetch repositories via http:// and https://. This error occurs if you compile git without the library present.
Install it (yum/dnf install libcurl-devel) and then reconfigure and recompile git. It should work.
Link: https://github.com/git/git/blob/b896f729e240d250cf56899e6a0073f6aa469f... | git clone from https URL fails, says it's 'remote-https' is not a git command and that templates werent' found |
1,465,385,311,000 |
I am trying to remove comments from a file which may be in any part of a line and span multiple lines.
struct my_struct{
field1;
field2; /** comment 1
*/ field3;
/* comment 2 */
} struct_name;
I need to get
struct my_struct{
field1;
field2;
field3;
} struct_name;
I tried using
grep -o '[^/*]*[^*... |
If you just want to remove anything between /* and */, and ignore all the quirks of the C language, like C99-style //-comments, quoted strings and backslash-escapes of newlines, then a simple Perl-regex should do:
perl -0777 -pe 's,/\*.*?\*/,,gs' inputfile
| Remove comments in a C file [duplicate] |
1,465,385,311,000 |
I need to get the source code of the "arch" command located in /usr/bin/arch for
macOS Catalina( see the output of sw_vers command below).
macOS Catalina
ProductName: Mac OS X
ProductVersion: 10.15.3
BuildVersion: 19D76
In case you need it, here are some architecture details:
MacBook-Pro 15-inch, 2019
Processo... |
The place to find the open source components of MacOS is https://opensource.apple.com/ , and the package where arch is included is called system_cmds.
Unfortunately, the links for Catalina (10.15.x) seem to be unavailable at the time of writing this (this is not uncommon, because Apple usually publishes the source wit... | Source code of arch command for macOS Catalina Version 10.15.3 (19D76) |
1,465,385,311,000 |
According to fs/proc/array.c:130, the following array defines various process states:
/*
* The task state array is a strange "bitmap" of
* reasons to sleep. Thus "running" is zero, and
* you can test for combinations of others with
* simple bit tests.
*/
static const char * const task_state_array[] = {
/* st... |
The task state represented by “X” isn’t TASK_DEAD, it’s the EXIT_DEAD exit state. TASK_DEAD itself isn’t a reportable state, and while EXIT_DEAD is, it isn’t supposed to be visible in practice.
EXIT_DEAD’s role is similar to what you describe for TASK_DEAD: a task’s exit state is set to EXIT_DEAD shortly before its ta... | In what circumstances will a process be in state X (dead)? |
1,465,385,311,000 |
I'm new to linux and my teacher asked me to learn about how to build Raspbian from the source code.
From what read in other questions, I need to download the Raspbian source code first. In some questions the link http://archive.raspbian.org/raspbian/pool/main/ and https://github.com/raspberrypi/linux appears to be the... |
Raspbian itself contains 22,544 source packages in its main repository, with 67,417 files to download (as of 2016, Raspbian Jessie) if you want all the source code. Rebuilding all that isn't something I'd consider doing manually...
If you really want to download all the source code for Raspbian, you should start by do... | How to download a whole raspbian source code? |
1,465,385,311,000 |
System: Linux Mint 19 Cinnamon, based on Ubuntu 18.04.
In this answer, I am being pointed at a different solution, other than installing directly from source.
Since I haven't ever used dget, I must have it installed first with:
$ sudo apt-get install devscripts
Upon the first suggested line:
$ dget -x http://deb.de... |
I am unsure if this is the right solution to my problem, but since it resolved the warning, I will add it here:
sudo apt-get install debian-keyring
As pointed out by Stephen Kitt, there is another possibility to disable verification with:
dget -x -u ...
but the above approach is better from the security standpoint.... | dpkg-source: warning: failed to verify signature |
1,465,385,311,000 |
No matter how many times I rebuild the plocate db I get:
/var/lib/plocate/plocate.db: has version 4294967295, expected 0 or 1; please rebuild it.
How in the world did I manage this??
/sbin/updatedb.plocate:
linux-vdso.so.1 (0x0000007f1c7d4000)
libzstd.so.1 => /lib/aarch64-linux-gnu/libzstd.so.1 (0x0000007f1c6... |
TL;DR this is due to a limitation in Android/termux/proot but is trivially worked around with a code change in plocate, which is in the 1.1.20 release.
4294967295 (i.e. 0xffffffff) is (uint32_t)-1. This is the value plocate's updatedb uses as a sentinel version number to detect an incompletely written database file.
W... | /var/lib/plocate/plocate.db: has version 4294967295, expected 0 or 1; please rebuild it |
1,465,385,311,000 |
These four files/folders were downloaded after I ran apt-get source bash to get the source code of the package bash in Ubuntu.
- bash-5.0
- bash_5.0-6ubuntu1.1.debian.tar.xz
- bash_5.0-6ubuntu1.1.dsc
- bash_5.0.orig.tar.xz
What are these four files? Which of these is the source code of the package bash?
|
bash_5.0-6ubuntu1.1.dsc is the source package control file; it describes the source package (it’s a text file, you can view it using your favourite text viewer or editor).
bash_5.0.orig.tar.xz contains the upstream source code, i.e. the archive you’d get from the Bash project itself (with no packaging).
bash_5.0-6ubun... | What is the difference between the three files downloaded on running 'apt-get source {package-name}' ? Which is the actual source code of the package? |
1,465,385,311,000 |
The bash shell in my production box is vulnerable to 'bashbug' vulnerability. https://securityblog.redhat.com/2014/09/24/bash-specially-crafted-environment-variables-code-injection-attack/
The version installed is
`$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)`
I am not able to use ... |
Bash patches are cumulative, the source for 4.3 is effectively 4.3.0, the patches are separate, and all of them should be applied in order, each one will bump you up a patch level. Rarely, a complete source release is made available from the official site, the last one was 3.2.48.
What you are observing is that the re... | Applying patch for bash failing |
1,465,385,311,000 |
I'm having a critical support issue with SLES that doesn't make any measurable progress (for months now).
So I wanted to have a look at the source code myself; maybe I can spot the issue.
(It seems a fatal bug was added between SLES15 SP2 and SP3 in the Xen Hypervisor that causes frequent server crashes due to RAM cor... |
All the GPL requires is that they make the source code available. (And not everything Linux is GPL.) They don't have to make it available in any convenient format. I'm guessing their internal revision control servers are private for reasons of their business model. Downloading SRPMs is likely your best bet.
Try so... | Where can I get the current source code for SUSE SLES products? |
1,465,385,311,000 |
I'd like to create a script that is able to install my desired set of packages in any Linux distro (initially create it to run in Ubuntu and later expand it to whichever) and basically function as an environment setup. Examples of such packages would be zsh, omz, fzf, autocomplete etc...
My question is this, should I ... |
I'd recommend to always prefer the native package manager for anything that needs to link against system libraries, or anything that other things on the target system might link against. Otherwise, you'll be going through the effort of making things work with distro quirks for every single platform you're targeting, a... | Rely on the existence of a package manager or install package via downloading the source? |
1,465,385,311,000 |
I ran
git clone https://git.savannah.gnu.org/git/bash.git
cd bash/
./configure
make
./bash
I noticed that the newly launched Bash instance did not inherit the environment, specifically the PS1 variable that defines the shell prompt, from the parent shell.
The inheritance works for /bin/bash
List of sourced files is t... |
First, you need to understand that PS1 is usually a
shell variable, which means it isn't inherited by the children. So unless you explicitly ran export PS1=... and made PS1 an environment variable, every new bash process will get the PS1 (and other shell variables) from the rc files and not from the parent. So you fir... | Why does Bash behave differently when compiled from source code? |
1,465,385,311,000 |
I'm a software developer and only in the last year or so have I been using Linux Mint over Windows as my working dev environment. For the last year I figured I'd do things my way and adapt as I learn the proper way to do things. So far so good. Relevant to this question, I've been putting my source code to my work an... |
/usr/local/src is the local equivalent of /usr/src, which the FHS describes as
Source code may be place placed in this subdirectory, only for reference purposes.
Neither /usr/src or /usr/local/src are intended as working directories, especially not for a specific user. All your data is supposed to live under your ho... | Where is the idiomatic place to put source code for my projects? [closed] |
1,465,385,311,000 |
I want to build a robot using some mini-computers like Raspberry-Pi, and using Linux OS upon. I think those boards (RPi, NanoPi, etc) have external SD card to boot OS from, and my code will go there (on SD card). So, how can I protect my code from someone who wants to copy it?
From my code, I mean my programs that are... |
To protect your data you have to have key, of any sort, which you can guard and control physically and be separately from your secret data. Password in your brains is example of such solution - it is physically guarded by owner, by memorizing it.
As password there might be some visual token for your super robot, like ... | How can I protect my robot code? |
1,465,385,311,000 |
For example, cat foo.c would print the whole file, cat foo.c | grep main will print the line where the main function is defined.
So how would I print the entire main function?
(I am on Ubuntu)
|
Depends a lot on source and, control over source, desired result etc.
In it's simplest form:
sed -n '/^int main(/,/^}/p' file.c
That would print everything between lines starting with int main( until } inclusive.
If you need to expand macros you could use the c preprocessor cpp then run it trough indent and finally ... | How would I print only the main function from a C source file? |
1,465,385,311,000 |
I have been playing with PureOS installation options (the ultimate goal is to install it dual boot with MacOS on a MacBook Air, but this is out of the scope of this question).
What I would like to see is how this "Boot loader location: Boot Partition (/boot)" option actually works behind the scenes (in particular, how... |
The link provided does indeed point to a package repository, but that package repository also includes all the source code for the packages. All the tarballs contain source code: in the example you show, the various .orig.tar.xz files contain the upstream source, and the .debian.tar.xz files contain the distribution-s... | Locating source code of the PureOS installer |
1,465,385,311,000 |
I just stumbled across a problem where the installed kernel sources don't match the kernel that I'm actually running.
I'm running 4.11.7-300.fc26.x86_64:
[root@localhost VirtualBoxGuestAdditions]# uname -r
4.11.7-300.fc26.x86_64
But the latest kernel sources don't seem to have the same version:
[root@localhost Virtu... |
I expect that this is merely a transient mirroring problem. Try
sudo dnf --refresh upgrade kernel-devel
(Or possibly just a general sudo dnf --refresh upgrade.)
| Latest kernel sources not available for installation? (Fedora 26 Beta) |
1,467,404,893,000 |
Currently we're using this command within a shell script to remove silence from audio files:
ffmpeg -i $INFILE -af silenceremove=0:0:0:-1:1:${NOISE_TOLERANCE}dB -ac 1 $SILENCED_FILE -y
This works fine except that it removes all the silence, causing the remaining audio to be squeezed together.
How can this be done whi... |
The best way that I've seen is by adding the -l flag to silence as follows:
sox in.wav out6.wav silence -l 1 0.1 1% -1 2.0 1%
I've copied this command from Example 6 of this very useful blog post called The Sox of Silence
| Remove silence from audio files while leaving gaps |
1,467,404,893,000 |
I'm writing a script that uses sox to record me talking.
Now I need sox to wait until it detects sound before it begins recording, and I do have that figured out. But I also need sox to exit once there has been silence for at least 3 seconds.
As it is now, I have to manually kill sox once I finish talking, otherwise s... |
Remove the negative sign from your original command:
rec /tmp/recording.flac rate 32k silence 1 0.1 3% 1 3.0 3%
When the "below count" is negative, the silence command will trim all silences from the middle of the file. When it's positive, it trims silence from the end of the file.
| End sox recording once silence is detected |
1,467,404,893,000 |
I have a test.wav file.
I need to use this file to process an application, with following properties:
monochannel
16 kHz sample rate
16-bit
Now, I'm using the following commands to attain these properties:
sox disturbence.wav -r 16000 disturbence_16000.wav
sox disturbence_16000.wav -c 1 disturbence_1600_mono.wav
so... |
sox disturbence.wav -r 16000 -c 1 -b 16 disturbence_16000_mono_16bit.wav
gives within one command
Sample rate of 16 kHz (-r 16000),
one channel (mono) (-c 1),
16 bits bit depth (-b 16).
| Sox: Convert a .wav file with required properties in a single command |
1,467,404,893,000 |
for a single .mp3, I can convert it to wav using
sox ./input/filename.mp3 ./output/filename.wav
I tried:
#!/bin/bash
for i in $(ls *mp3)
do
sox -t wav $i waves/$(basename $i)
done
But it throws the following error:
sox FAIL formats: can't open input file `filename.mp3': WAVE: RIFF header not found
How would... |
It sounds like you're running into a problem with spaces in the filename. If you have a file named "My Greatest Hits.mp3", your command will try to convert the three different files named "My", "Greatest", and "Hits.mp3". Instead of using the "$()" syntax, just use "*.mp3" in the for line, and make sure to quote the f... | batch convert mp3 files to wav using sox |
1,467,404,893,000 |
I have done this:
me@riverbrain:~/sgf$ echo "test" | text2wave -otype raw -F 16000 >> test.raw
which produced a headerless audio file. The wonderful thing about this file is that it can be concatenated (using cat, like text) with another raw audio file.
Of course, I've got a problem. The problem is that I can't play ... |
It can vary—but at least for me, text2wave produces 1-channel, 16-bit, signed integer PCM. These are fairly normal—and it'll be very clear when you have them right (e.g., if you unsigned-integer by mistake, you'd get extremely distorted sound)
With play, that looks like:
play -r 16000 -b 16 -c 1 -e signed-integer /tmp... | What and how is the encoding of a raw (headerless) audio file? |
1,467,404,893,000 |
I've got multiple audiobooks that are stored in large mp3s. And I'm trying to split these large mp3s into multiple smaller files.
I've found a tool that can detect silence in audio files and split audio files based on this "delimiter".
Here is an example:
sox -V3 audiobook.mp3 audiobook_part_.mp3 \
silence 1 0.5 0.1% ... |
You can preserve all the silences in the split parts with some small changes. Starting with your original command:
silence 1 0.5 0.1% 1 0.5 0.1%
The first triplet of values means removes silence, if any, at the start until .5 seconds of sound above .1%. The second triplet means stop when there is at least .5 seco... | sox: Split audio on silence but keep silence |
1,467,404,893,000 |
How can you play a sound slower or faster? That would be useful for listening carefully one audio passage or to listen fast forward to find a concrete passage.
Is there something with the play sox command that would do this? Alternative simple solutions also welcome.
|
I find almost half a dozen softwares recommended here.
Audacity
MPlayer
Rubberband
Play It Slowly
Ardour
LMMS
MuSE
Rosegarden
| Play a sound file slower or faster |
1,467,404,893,000 |
sox is probably the one linux program that continues to frustrate me. At the same time, I am awed by what it can do, and I'd like to get close to being fluent in it, if not mastering it.
Today, I've spent about 2 hours trying to get sox to read bytes from parec via a pipe.
The parec bytes are a pulseaudio "sink". In o... |
The -t option needs to come before the filename it applies to. Also, -t pulse means to read directly from (or write to) the PulseAudio daemon; it's not a file format as such. The type name for raw audio is raw.
Try this:
parec ... | sox -t raw -b 16 -e signed -c 2 -r 44100 - hmm.ogg ...
(where ... means to keep the... | pipe the output of parec to sox |
1,467,404,893,000 |
I'm trying to put the "sox" utility in a two pipes command to resample a mono 44kHz audio file to a 16kHz audio file.
It works fine with a single pipe :
$ speexdec toto.oga - | sox -V -t raw -b 16 -e signed -c 1 -r 44.1k - -r 16k toto.wav
But when I add onather pipe, the sox utility complains :
$ speexdec toto.oga - ... |
You need to declare the type of the sox output by adding -t wav before the second -.
When it's a file name, sox peeps at the name and deduces the type from there, but when it's stdout, the type needs to be declared.
You might also want to declare all other settings as well (-b 16 -e signed -c 1) rather than assuming t... | sox in between two pipes to resample a voice audio |
1,467,404,893,000 |
I can run this command:
$ play mylist.m3u
And music plays.
I can then press Ctrl-Z to suspend the job, and issue bg to have it run in the background.
However, if I then run disown and exit, the music stops playing, even though the play command still shows up in ps.
I would expect the music to keep playing.
Also inter... |
SoX wants/needs input & output... by typing 'play xxxx' in the console, you're running it normally, with stdin & stdout (& stderr) all connected.
When you background the job (with &), it starts, then is paused since it's waiting for access to stdin & stdout.
Same thing occurs when you 'nohup' a job. If it needs keybo... | Why do 'nohup' and 'disown' not work on SoX (invoked as 'play') |
1,467,404,893,000 |
I've found a solution that doesn't work by me:
audio - Monitoring the microphone level with a command line tool in Linux - Super User
https://superuser.com/questions/306701/monitoring-the-microphone-level-with-a-command-line-tool-in-linux
The problem is that they are using Maximum amplitude to detect sound. However it... |
(Answer based on various comments, as this method seems to be acceptable, and comments are not guaranteed to stay.)
Look at the first recording ("10 secs of silence") in an audio editor, e.g. audacity. You'll see a DC (very low frequency) component when the level goes from 1 at 0 secs to -1 at 1 secs to 0.5 at 1.5 sec... | How to monitor microphone volume level? |
1,467,404,893,000 |
Is it possible to convert a mp4 file to mp3 or flac, clearing background noises in the process?
Or is it possible to run audacity totally trough shell, No GUI?
|
If the background noise has some repetitive structure to it, you can remove it with the noiseprof and noisered effects of sox, see e.g. this script. Relevant bits repeated for convenience:
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/... | How to clear background noises with sox |
1,467,404,893,000 |
Is there anyway to shuffle songs using play on a folder using SoX?
play ~/Music/*/**
|
You can use sort -R to reorder the file list into "random" order. The command could be the following:
find ~/Music -type f | sort -R | xargs -I + play +
Here find ~/Music -type f results in a list of of all files in the Music subtree, recursively. The resulting pathname list is then "sorted" into a random order by so... | Shuffle Using SoX? |
1,467,404,893,000 |
I know how to play a tone for a specific amount of time using SOX.
play -n synth 5 sin 347
I know how to save a tone using SOX.
sox -n note.mp3 synth 5 sin 347
Question is : How can I save a longer tone (hours) without the sound actually playing and not actually having to wait hours for the file to generate?
|
Answer: @derobert pointed out the "sox" and "play" command are part of the same package but does different thing. The 3600 below is the time interval in seconds.
sox -n note.mp3 synth 3600 sin 347
The above code will generate an hour long tone without playing it.
play -n note.mp3 synth 3600 sin 347
The above code w... | Generating a long sound file with SOX without actually playing the tone |
1,467,404,893,000 |
I'm processing a variety of audio files in a bunch of different formats and I'd like to unify their format and configuration using FFMPEG and SoX.
There are two steps to my process:
Convert the file, whatever it may originally be, to a PCM 16-bit little-endian WAV file:
ffmpeg -i input.wav -c:a pcm_s16le output.wav
P... |
I think sox needs to seek its input if it is to determine the input format from the file's header, and that's incompatible with a pipe.
I think ffmpeg can do all you want, though I'm not completely sure. I'm unfamiliar with it and the documentation is clear as mud.
ffmpeg -i "$input" -compression_level 9 -ac 2 -ab 441... | Piping Sox and FFMPEG together |
1,467,404,893,000 |
I'm trying to pipe audio to sox and I get Error "sox FAIL formats: bad input format for `-': sampling rate was not specified"
parec -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor --rate=16000 --channels=1 | sox -t raw - output.wav silence 1 0.3 0.1% 1 0.3 0.1% : newfile : restart
This is output of the comma... |
A raw stream does not contain any meta-information about its format, so you have to tell sox about it:
parec ... | sox -t raw -r 16k -e signed -b 16 -c 1 ...
| Sox format for stream with sample spec 's16le 1ch 16000Hz', channel map 'mono' |
1,467,404,893,000 |
I looked at the following link: Trim audio file using start and stop times
But this doesn't completely answer my question. My problem is: I have an audio file such as abc.mp3 or abc.wav. I also have a text file containing start and end timestamps:
0.0 1.0 silence
1.0 5.0 music
6.0 8.0 speech
I want to spli... |
I've just had a quick go at it, very little in the way of testing so maybe it'll be of help. Below relies on ffmpeg-python, but it wouldn't be a challenge to write with subprocess anyway.
At the moment the time input file is just treated as pairs of times, start and end, and then an output name. Missing names are repl... | Split audio into several pieces based on timestamps from a text file with sox or ffmpeg |
1,467,404,893,000 |
I have a list of files with names prefix_0000.mp3 ... prefix_x.mp3, where max(x) = 9999.
I have the bash script:
...
sox prefix_*.mp3 script_name_output.mp3 # this fails because maximum number is 348
rm prefix_*.mp3
...
How can I best split the ordered list of mp3 files into sublists (with retaining ordering) and gra... |
First, gather the list into a Bash array. If the files are in the current directory, you can use
files=(prefix_????.mp3)
Alternatively, you can use find and sort,
IFS=$'\n' ;
files=($(find . -name 'prefix_*.mp3' printf '%p\n' | sort -d))
Setting IFS tells Bash to split only at newlines. If your file and directory na... | Splitting the ordered list into sublists |
1,467,404,893,000 |
I need a way in which I can play an audio file in the terminal, and tell it
from what time step it should start from?..
Example could be to start the audio file from 00:10:00... is that possible?
|
Sox comes with the play command which takes the same arguments as sox. These include the trim effect which can specify a starting position. Effects come after the filename. So you can do, for example,
play myfile.mp3 trim 10:00
| Play audio file from a certain time step in terminal? |
1,467,404,893,000 |
I wanted to analyze 5 seconds of an audio file beginning from 50 seconds.
So I ran the following command:
sox audio.wav -n stat trim 50 5
But the output contained:
...
Length (seconds): 55.296000
...
But I expected only 5 seconds, not 55.
What did I do wrong? I thought that 50 was the start and 5 - the duration.... |
The effects function as a chain, so the stat effect feeds into trim, swap them around and it will work, e.g.:
sox audio.wav -n trim 50 5 stat
| How can I analyze a segment of an audio file with sox? |
1,467,404,893,000 |
Problem:
I don't hear anything on my sound system when playing audio.
Question:
What is the minimal set of programs required to play something on my machines audio jack or S/PDIF output?
How did I get there?
My system is an up-to-date Debian Stretch system which got created with debootstrap. The system is an Intel NUC... |
Have you checked the volume settings? The system defaults were chosen to be quiet or outright muted because people were annoyed with getting blasted by full-volume sound output on new, unconfigured systems.
Since /proc/asound/cards indicates that the name of your chipset-integrated soundcard is "PCH", try this (instal... | What is the minimal set of programs required to play something on my machines audio jack or S/PDIF output? |
1,467,404,893,000 |
I want to set up a daemon that starts recording video with sound when it detects noise or movement. There are tools that do that separately but can they be done at the same time? Can I set up motion in a way that when it detects motion it executes a script? Can I do the same with SOX?
|
I know this is a very old question but I may be able to help someone (like me, few years ago) who stumble across this in a search...
I found the above answer from ridgy when I was looking to record and stream audio from Motion and it sent me off to develop a successful solution, for me at least. My use case is recordi... | sound recording with motion? |
1,467,404,893,000 |
How can I add an audio file (OGG vorbis) into a shell script making the script as small as possible and at the same time being able to execute it on as most systems as possible? I want the audio file be played.
I don’t want it to be uuencoded, because sharutils are not installed on many systems. base64 is nice, but ma... |
With the following script it works (using mplayer, which is probably not present on many systems).
#!/bin/sh
grep -A 1000 --text -m 1 ^Ogg "$0" | mplayer -
exit
OggS^@^B^@^@^@^@^@^@^@^@^]f<8a>g^@^@^@^@lY߸^A^^^Avorbis^@^@^@^@^A"V^@^@^...
The last line is the beginning of the audio file binary.
The grep command search... | How to add an audio file to a shell script |
1,467,404,893,000 |
script
#!/bin/bash --
# record from microphone
rec --channels 1 /tmp/rec.sox trim 0.9 band 4k noiseprof /tmp/noiseprof &&
# convert to mp3
sox /tmp/rec.sox --compression 0.01 /tmp/rec.mp3 trim 0 -0.1 &&
# play recording to test for noise
play /tmp/rec.mp3 &&
printf "\nRemove noise? "
read reply
# If there's n... |
What happens is that one of your SoX programs (sox, play, rec) has changed how stdin is behaving, making it non-blocking. Typically, something is calling fcntl(0, F_SETFL, O_NONBLOCK).
When a call to the read() system call is made on a non-blocking file descriptor, the call does not wait: either there is already somet... | Why does `read` fail saying "read error: 0: Resource temporarily unavailable"? |
1,467,404,893,000 |
I have a test.wav file that I wanna play through speaker using ALSA. I also have sox installed on the system. All sound cards are installed properly. aplay -L and arecord -L return the correct value.
However I wasn't able to play this test.wav.
aplay -c1 -r 48000 -f S16_LE test.wav
$ Playing WAVE 'test.wav': Signed 16... |
By changing the configuration of the user pi to use hw devices, you have disabled all automatic sample format conversions.
To set only the card number, use:
defaults.pcm.card 0
defaults.ctl.card 0
To change this for all users instead, put this into /etc/asound.conf.
| ALSA aplay mono file but returns channel count non available |
1,467,404,893,000 |
I have two audio-files and want to mix them with SoX using the -m, --combine mix option.
Both files have the same bpm, but not the same length, meaning I need to loop one file, but not the other. Does anyone on here know (if possible) how to do this?
I managed to create a looped file with sox by using the repeat opti... |
got to use the pipe option -p, --sox-pipe otherwise the first command is not passing anything to stdout and the second command only gets one file for mixing:
sox FAIL sox: Not enough input filenames specified
Using a pipe with the -p option does the job:
sox one-bar.flac -p repeat 4 | sox - -m four-bars.wav output.fl... | SoX - mixing two audio tracks but looping/repeating only one |
1,467,404,893,000 |
Is there any way to play last N seconds of an mp3 file on bash commandline?
|
Figured out. Similar to https://stackoverflow.com/questions/9667081/how-do-you-trim-the-audio-files-end-using-sox
Solution:
play nameOfMp3 reverse trim 0 N reverse
(where N is the number of seconds).
| Play last few seconds of mp3 |
1,467,404,893,000 |
I need to split wav files into multiple 10-second-long wav files, but each resulting wav file must be exactly 10 seconds in length, adding silence if needed – so if a wav file's duration in seconds isn't a multiple of 10, the last wav file should be padded with silence.
I've seen some answers (1, 2, 3) which show how ... |
Split the files, inspect the resulting files (for i in *wav), if (length < 10 seconds), pad them.
To get the wave file length: sox --info -D file.wav
To pad the wave file: https://superuser.com/questions/579008/add-1-second-of-silence-to-audio-through-ffmpeg
Maybe do some calculations :-)
| split wav file into parts of equal duration, padding with silence if needed |
1,467,404,893,000 |
I have a folder with several MP3 files that I need to extract 10-15 seconds of audio from. I would also like to rename these by appending sample-(name).mp3 to the converted files.
How can I do this via Shell Script?
|
If you want/need to use sox for this you can use its trim command:
for i in *.mp3
do
sox "$i" sample-"$i" trim 0 10
done
The splitting you can also do with the commandline utility that is part of mp3splt. You explicitly set the output file with -o, so the originals are not touched, just remove them after you are d... | Create SOX batch script to extract first 15 seconds and rename multiple files in folder |
1,467,404,893,000 |
I use the following script to monitor my microphone:
while true; do
printf "$(AUDIODEV=hw:2,0 rec -n stat trim 0 1 2>&1 |
awk 'BEGIN { ORS="" } /^Maximum amplitude/ { print "Max. amplitude: "$3}
/^Rough\s+frequency/ { print " Frequency: "$3}
/^Maximum\s+delta/ { print " Max. del... |
I found a solution in the meanwhile. It is based on piping the output of rec to base64 so that it can be encoded to ASCII and stored in a bash variable. If it is time to analyze the segment's volume and frequency I run base --decode on the variable contents. In the script below only volume is analyzed. If it exceeds t... | Monitor microphone and save filtered segments |
1,467,404,893,000 |
When I use the play command provided by SoX, sometimes the playback information contains a number labeled Hd, which the manpage doesn’t seem to mention. What does it mean?
$ play song.mp3
In:72.5% 00:04:43.38 [00:01:47.73] Out:12.5M [ -===|==== ] Hd:4.3 Clip:0
|
Have a look at this thread on the SoX mailing list: [SoX-users] What does Hd:0.0 mean?:
The first answer is:
Rene Maurer <renemaur@...>:
Can anyone tell me what "Hd:" means. Playing songs let this value
change from time to time (Hd:0.0, Hd:1.6, Hd:4.9, Hd:0.0 for
example).
It's the headroom in dB (in case ... | What is the Hd output of SoX’s play? |
1,371,844,630,000 |
I have a Clonezilla installation on a USB stick and I'd like to make some modifications to the operating system. Specifically, I'd like to insert a runnable script into /usr/sbin to make it easy to run my own backup command to make backups less painful.
The main filesystem lives under /live/filesystem.squashfs on the... |
This assumes that you are root and that squashfs-tools is installed on your system:
Copy filesystem.squashfs to some empty dir, e.g.:
cp /path/to/filesystem.squashfs /path/to/workdir
cd /path/to/workdir
Unpack the file then move it somewhere else (so you still have it as a backup):
unsquashfs filesystem.squashfs
mv ... | Mounting a squashfs filesystem in read-write |
1,371,844,630,000 |
Why couldn't the Live ISOs just be a minimal Linux system with an installer? Is there any reason to use squashfs to hold the root of the filesystem? Is it just for better compression, or are there other reasons?
I've seen some answers (and comments) say that it's for read-only reasons. What about persistence, like wha... |
There are a couple of important reasons for this, but the big two are space constraints, and requirements from the filesystem itself.
SquashFS is a highly optimized filesystem image format that provides, among other benefits:
High levels of data compression.
Built-in block-level deduplication (any given block is stor... | Why is the base system of Live ISOs for Linux distros usually stored with squashfs? |
1,371,844,630,000 |
When I use Unetbootin to put a Linux ISO on a USB drive, it proceeds quite quickly until it gets to filesystem.squashfs, which takes longer to process than absolutely everything else combined.
Is this writing a new filesystem to the USB, or is it copying some huge filesystem-dependent file? If so, is there a way to o... |
Most major distributions use squashfs to hold their live CD. squashfs is intended to be used for read-only filesystems, which is exactly what a live CD is.
Decompressing filesystem.squashfs takes longer than any other process because filesystem.squashfs contains the entire system.
For more information, look at the wi... | What is filesystem.squashfs and why does it take so long to load on to bootable media? |
1,371,844,630,000 |
I'm trying to modify a firmware file by unsquashing it, editing my files and squash it again. But I got problems with the device which does not accept the file because of different squashfs types (as I suppose). Here's the output on my dev box:
original file:
user@ubuntuVM:~$ unsquashfs -s main-fs.5_0
Reading a diffe... |
Linux kernels before 2.6.29 don't accept SquashFS version 4 filesystems (read here). This will probably the cause why your device does not boot with it.
In order to build a SquashFS v3 image, you'll need an older version of the squashfs-tools package. The latest supported release of Ubuntu including this is the old Ha... | SQUASHFS 3 vs 4 |
1,371,844,630,000 |
I want to change some files on my router. Firstly i can change everything in /var, but i want to change /etc/fstab. when i try to change it, i get an error message that says filesystem is read only.
Busybox inside router, has limited commands, so i had got busybox binary for mips http://www.busybox.net/downloads/binar... |
This isn't related to BusyBox. BusyBox is a set of unix utilities designed for low-resource environments such as routers. Your router's root filesystem is mounted read-only because it's stored on SquashFS, a compressed filesystem which cannot be written to. A SquashFS filesystem is compressed in one go when the filesy... | how to make read only filesystem writable on busybox? |
1,371,844,630,000 |
I enjoy using squashfs for compression because of the simplicity of mounting them as loop devices to access the files inside.
I have a lot of rar, tgz and zip files that I would like to convert to squashfs.
In this answer, I saw that it is possible to use a pseudo file when compressing a disk image to squashfs to avoi... |
You could mount them with fuse-zip or archivemount and then create the squashfs file from the mount point.
For example, this would work for a zip file:
$ mkdir /tmp/zmnt
$ fuse-zip -r /path/to/file1.zip /tmp/zmnt
$ mksquashfs /tmp/zmnt /path/to/file1.squashfs
$ fusermount -u /tmp/zmnt
| How to convert from rar or tgz to squashfs without having to extract to temporary folder? |
1,371,844,630,000 |
I'm using Ubuntu 12.04. I want to unsquash an lzma image. I have done
sudo apt-get squashfs-tools
Now, when I do
unsquashfs <squashed_image_filename>
I get
Filesystem uses lzma compression, this is unsupported by this version
I know my squashed image is lzma. How do I install support for lzma? I have downloaded th... |
Thanks to @msw, I figured out the package names for Ubuntu. Thank you! Here's the full steps for someone in the future.
Get source here: http://sourceforge.net/projects/squashfs/
# sudo apt-get install lzma-dev
# sudo apt-get install liblzma-dev
# tar -zxvf squashfs4.2.tar.gz
# cd squashfs4.2/squashfs-tools: Edit Make... | How to use 'unsquashfs' with lzma? |
1,371,844,630,000 |
In this answer on a previous question, I found out how to modify files in a squashfs filesystem:
# unsquash the filesystem to a local directory
sudo cp /media/clonezilla/live/filesystem.squashfs ./
sudo unsquashfs filesystem.squashfs
# now, insert my own script which I want as part of the distribution
sudo cp ~/autoba... |
As I said in my other answer you have to move the old filesystem.squashfs to another location (or rename it) before repacking your modified squashfs-root into a new filesystem.squashfs:
mv filesystem.squashfs /path/to/backup/
or
mv filesystem.squashfs filesystem.squashfs.old
then:
mksquashfs squashfs-root filesystem... | Merging preexisting source folders in mksquashfs |
1,371,844,630,000 |
I am using Ubuntu 12.04 LTS 64 bits to chroot into a just extracted to my harddrive (with unsquashfs) Squash File System from a Kali Linux v1.0.5 32 bits pendrive for customizations:
luis@Fujur:$ sudo chroot /media/Datos/Temporal/squashfs/modificando
root@Fujur:/# ls
0 boot etc initrd.img media opt root sbi... |
The line
/dev/sda7 on /media/Datos type fuseblk (rw)
from mount's output tells you that /media/Datos is an NTFS partition (type fuseblk).
NTFS cannot store ownership and permissions in the same way Linux/Unix filesystems like ext{2..4} can. That's why you can set ownership/permissions but they do not persist.
You'll... | Can not change permissions of files/directories in a chrooted filesystem |
1,371,844,630,000 |
Situation: I've got a larger (>10GB) read-only collection of small files with loads of duplicates that I need to have available on multiple machines, even on different file systems. We can assume Linux kernel > 5.3.0.
One solution would be to put these into a squashfs image file, use deduplication and zstd compression... |
Mounting a squashfs file system doesn’t involve decompressing it into memory; decompression is done on the fly, as necessary. There is a small internal cache to avoid repeatedly decompressing the same data, but that’s all.
squashfs file systems can store up to 264 bytes of data, so it wouldn’t be practical to decompre... | Does mounting squashfs put the whole filesystem in RAM? |
1,371,844,630,000 |
I am working on an embedded device.
The fstab shows the following info:
<file system> <mount pt> <type> <options> <dump> <pass>
/dev/root / ext2 rw,noauto 0 1
proc /proc proc defaults 0 ... |
Your root filesystem is squashfs, which saves some flash space by compressing everything, but as a result is read-only. You can not mount it read-write. Instead, you reflash the device with a new squashfs image.
If you need writable storage, you have to partition your flash and mount a second, writable filesystem, of ... | Remount squashfs root filessytem read-write [duplicate] |
1,371,844,630,000 |
I've created a gentoo-live system which should be booted from a CF-card. The whole file-system is in a squashfs. I've created a custom initrd which first mounts the CF-card and from there the squashed filesystem into what will become /.
I'd like /etc to be writable so I've copied it to the CF-card added a bind. This h... |
BusyBox's built-in mount command doesn't recognize -B; you'll have to use -o bind:
mount -o bind /mnt/flash/etc /mnt/root/etc
Also, I think the remounting is unnecessary if /mnt/flash is already writable. But try fixing the bind mounting first.
| Mount /etc from disc into squashfs |
1,371,844,630,000 |
From debian stretch man page:
Filesystem filter options
-p PSEUDO_DEFINITION
Add pseudo file definition.
-pf PSEUDO_FILE
Add list of pseudo file definitions.
-sort SORT_FILE
sort files according to priorities in SORT_FILE. One file or dir with priority per line. Priority -32768 to 32767... |
There is more information in the README that might be part of the distributed package, or can be seen here 3.8 Pseudo file support.
For example,
-p 'mychardev c 666 root root 100 1'
creates a character device with major/minor 100/1.
Similarly, if you have a file mylist holding the lines
mydir d 777 0 0
mydir/... | Details(examples) of "pseudo-definition", "pseudo-file", "sort_file" for mksquashfs? |
1,371,844,630,000 |
I'm trying to use a compressed squashfs ubi volume as my root file system. The idea is to have two ubi volumes. Volume one contains a read-only squashfs file system. Volume two is re-sizable and uses the remaining flash space. It contains a writable ubifs file system. These two ubi volumes are to be overlayed using ov... |
Squashfs needs a block device to run, thus you need the block emulation over UBI. First make sure it is enabled in your kernel.
You can test this by using the ubiblock command on a running system. For example, running ubiblock -c /dev/ubi0_0 will create the devnode /dev/ubiblock0_0.
Once you have the dependency, you ... | Using squashfs on top of ubi as root file system |
1,371,844,630,000 |
Debian 7.0, I extracted the firmware.bin image using binwalk. The extracted content is squashfs-root folder containing subdirectories, and a separate file.squashfs file. I tried unsquashfs this file.squashfs file, but operation fails:
unsquashfs -l file.squashfs
Can't find a SQUASHFS superblock on file.squashfs
What... |
Since file doesn't recognize it, the vendor probably used a custom SquashFS magic signature. I expect that unsquashfs is also giving you an error about not being able to find a valid superblock.
Give sasquatch a try; it's a modified version of unsquashfs that attempts to support such vendor hacks.
| unsquashfs fails |
1,371,844,630,000 |
I am looking for something that will find the squashed filesystem, and the pass the output to unsquash the fs and it would have to be an absolute path outside the squashfs.
example
/tmp/mnt/live/filesystem.squashfs
desired output
/tmp/unsquashedfs/files
I am fooling with lines of code like
find /tmp/mnt -iname '*.s... |
You're basically looking for
find /tmp/mnt -iname '*.squashfs' -exec unsquashfs {} \;
{} is replaced by the path to the matched file.
If you want to specify which directory to extract to, pass the -d option.
find /tmp/mnt -iname '*.squashfs' -exec unsquashfs -d /tmp/unsquashedfs/files {} \;
| Pipe Find Results for '*.squashfs' to unsquashfs |
1,371,844,630,000 |
I would like to chroot into a Live USB Linux distro, if such thing is possible. I don't know if there is a generic method, so I will detail my specific test.
I am testing Kali Linux v1.0.5 Live USB created from Windows using "Universal USB Installer".
This is the root of the pendrive:
23/12/2013 01:12 am <DIR> ... |
After some research, it seems that SquashFS is a read-only filesystem, and writing is not possible into it, so, even when you could chroot into it by installing squashfs support, the only way to change the contents is something like these instructions resumed to:
Mount the SquashFS and extract the contents to a loop... | How can I chroot into a live filesystem.squashfs Linux distribution? |
1,371,844,630,000 |
Here I'm trying to create a squashfs filesystem but the resulting image is bigger than the original version and not because I added a file or anything as I only modified some configuration files.
What I'm trying to do is modify the existing squashfs filesystem on a live usb and delete some info to start the OS in a lo... |
Cannot comment so I'm writing an answer:
1) I agree with Patrick that the most probably source of your problems is hardlink 'multiplication'. With a normal cp you create as many copies of a hardlinked file as the hardlink count was. Use rsync or cp -a instead.
2) An even better solution would be to simply unsquashfs t... | Compression Level Mksquashfs |
1,371,844,630,000 |
Do you know what initramfs-kernel mean?
I know squashfs-factory/squashfs-sysupgrade.
How can I do it or what is it? which is better?
I just don't understand what the initramfs-kernel mean.
I have Linksys 1900ACS v2 and D-Link DL-860l B1, but I only use squashfs-factory and squashfs-sysupgrade.
What does the initramf... |
The initramfs OpenWRT/LEDE kernel builds are including the rootfs image into initramfs, attaching it to the kernel so it will put the filesystem in a ramdisk during bootup and utilize it as /. You don't need such builds if the regular flash-based storage works for you, as it won't allow any persistent configuration by... | wrt (openwrt / lede) initramfs |
1,371,844,630,000 |
Embedded device, Linux version 2.6.26.5, U-Boot 2009.03 bootloader. ARM Linux Kernel Image on NAND flash, loading from NAND.
How to access the filesystem as the root user, and to reset the root password? Is it possible to get this by supplying single boot argument (single-user mode) to Linux kernel via U-boot paramete... |
The correct command for this board is:
setenv bootargs ${bootargs} single init=/bin/sh
(there is no bash installed)
| Access the filesystem as the root user |
1,371,844,630,000 |
I have a directory containing a root filesystem that I SquashFS and then mount as r/o on other boxes.
However, before SquashFS'ing, i want to clear all the user-namespace xattrs from the filesystem. This is trivial to do with a small getfattr and setfattr loop script, but I want to avoid introducing those as a depende... |
GNU tar can read xattrs and do filtering on them, see https://www.gnu.org/software/tar/manual/html_node/Extended-File-Attributes.html.
A Squashfs filesystem can now be created from a tar archive using sqfstar (in version 4.5 and later).
So something like
tar --xattrs --xattrs-exclude='user.*' -c your-directory | sqfst... | Ideas to clear user xattrs from files without get/setfattr |
1,371,844,630,000 |
We are using a Centos LXC container with the rootfs contained in a squashfs filesystem. I really like the fact that a user cannot edit the rootfs from the host.
During the development, developers would infact like to make changes to the filesystem, and I'd like to move to an overlayfs. But I notice that although the u... |
lxc.pre.mount gets executed before the rootfs gets loaded:
lxc.hook.pre-mount = /var/lib/lxc/container0/mount-squashfs.sh
lxc.rootfs.path = overlayfs:/var/lib/lxc/container0/rootfs:/var/lib/lxc/container0/delta0
And in the mount script:
#!/bin/bash
mount -nt squashfs -o ro /var/lib/lxc/container0/rootfs.sqsh /var/lib... | LXC Container with Overlayfs/Squashfs |
1,444,351,101,000 |
I'd like to set ssh_config so after just typing ssh my_hostname i end up in specific folder. Just like I would type cd /folder/another_one/much_much_deeper/.
How can i achieve that?
EDIT. It's have been marked as duplicate of "How to ssh into dir..." yet it is not my question.
I know i can execute any commands by tail... |
There wasn't a way to do that, until OpenSSH 7.6. From manual:
RemoteCommand
Specifies a command to execute on the remote machine after successfully connecting to the server. The command string extends to the end of the line, and is executed with the user's shell. Arguments to RemoteCommand accept the tokens describe... | Remote command in ssh config file |
1,444,351,101,000 |
Currently I use Fish as my main shell on local and remote hosts.
I connect to remote hosts via ssh and sftp. I wanted to open or reuse a remote tmux whenever I connect, automatically, by default; so I added this to my ~/.ssh/config:
Host example.com
RemoteCommand tmux a; or tmux
RequestTTY yes
The problem is that now... |
This doesn't answer directly the question. However it has become for me the fix to the root problem, so I think it deserves a post.
What I really wanted is to auto-enter tmux. Instead, I just started using byobu, which builds on top of tmux but is way more comfortable. For example, it supports this use case out of the... | How to configure SSH with a RemoteCommand only for interactive sessions (i.e. without command, or not sftp) |
1,444,351,101,000 |
I want to set up an alias in my config file that has the same result as this command:
ssh -N devdb -L 1234:127.0.0.1:1234
My .ssh/config entry for devdb:
Host devdb
User someuser
HostName the_hostname
LocalForward 1234 127.0.0.1:1234
What do I put in the above config to not start a shell?
|
So in ssh.c for OpenSSH 7.6p1 we find
case 'N':
no_shell_flag = 1;
options.request_tty = REQUEST_TTY_NO;
so -N does two things:
the no_shell_flag only appears in ssh.c and is only enabled for the -W or -N options, otherwise it appears in some logic blocks related t... | What is the .ssh/config corresponding option for ssh -N |
1,444,351,101,000 |
I have defined a ssh_config file with all the hosts to which I connect on a regular basis. I like to start/connect to a tmux session upon connection to the host, so I've added the line RemoteCommand tmux new -ADs remote in my config. The problem is that if at some point I want to use rsync over ssh (which I do every n... |
Don't put RemoteCommand in the configuration file. Having RemoteCommand is occasionally useful to define an alias for a host such that ssh myalias runs a specific command. It isn't useful in a general-purpose entry. As you've noticed, it prevents doing anything other than running that specific command: you can't use r... | How to bypass RemoteCommand option in ssh_config |
1,444,351,101,000 |
I get the following output if I run the following command:
-bash-3.2$ ssh -o "StrictHostKeyChecking no" 192.168.1.77
Warning: Permanently added '192.168.1.77' (RSA) to the list of known hosts.
Last login: Fri Jul 4 10:49:11 2014 from chlorine.example.com
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
-b... |
I see couple of more options from the answer here.
Option 1:
-o "UserKnownHostsFile /dev/null"
Option 2:
If you want this behavior because you're working with cloud servers (AWS EC2, Rackspace CloudServers etc.) or you're constantly provisioning new images in Vagrant you may want to update your SSH config instead of ... | Using SSH to connect to a new server without storing the host keys in the $HOME/.ssh/known_host file |
1,444,351,101,000 |
I have a host which I ssh into. Sometimes I'm inside the same network, and can ssh directly into it, other times I'm outside it and I need to use a proxy.
Because ssh via the proxy server is much slower than direct, I'd like to have my ssh config set up such that I try to connect directly, falling back to the proxy if... |
Match is rather on-par with Host. It doesn't exist as a subset of Host the way other options do.
But you can specify multiple criteria on a match, and they appear to operate as a short-circuit AND. So this should be possible and useful for you:
Match host target_host exec not_inside_network
ProxyCommand ssh -W %... | Only apply Match keyword to single Host in ssh config |
1,444,351,101,000 |
I would like to specify a specific identity file based on the user I am ssh'ing as to a server.
For example when ssh as user1 from host 1 to host 2 as user1
[user1@host1 ~]$ ssh user1@host2
I would like to use a certain identity file. However when I ssh as user1 from host1 to host2 as user2, I would like to use a di... |
You should be able to do this with the Match directive e.g.
Host host2
HostName host2.some.dom.ain
Match user user1
IdentityFile ~/.ssh/id_user1
Match user user2
Identityfile ~/.ssh/id_user2
| Specify Specific Identity file when ssh'ing as certain user in ~/.ssh/config |
1,444,351,101,000 |
I have changed some stuff within the sshd_config file and want to reset the file to its default settings. How would I go about doing this?
|
The ssh default config file is on /private/etc/ssh/sshd_config, you can copy it to .ssh directory by the following command
sudo cp /private/etc/ssh/sshd_config ~/.ssh/config
Then restart SSHD:
sudo launchctl stop com.openssh.sshd
sudo launchctl start com.openssh.sshd
| How to reset the sshd_config file to its default settings |
1,444,351,101,000 |
Problem description
I try to connect to remote server in one of two panels of Midnight Commander using SFTP link... submenu. Unfortunately, mc does not pass my ~/.ssh/config file to sftp. Therefore typing sftp://myhostalias results in error message
Cannot chdir to "/sftp://myhostalias"
Here is a content of ~/.ssh/c... |
One should use Shell link... submenu instead of SFTP link... one. Type something like this in the address field: sh://myhostalias/~ or simply myhostalias (see ssh_config example above).
Concerning SFTP link..., I didn't manage to use it that way from mc gui. Anyway, using aliases with sftp in CLI is straightforward.
| Midnight Commander: sftp connection using aliases from ssh config |
1,444,351,101,000 |
I have a configuration as below in my ~/.ssh/config file:
Host xxx
HostName 127.0.0.1
Port 2222
User gigi
ServerAliveInterval 30
IdentityFile ~/blablabla
# CertificateFile ~/blablabla-cert.pub
which works fine but I'm curious about how would one generate the CertificateFile if really wants to ... |
The certificate model of authentication used by SSH is a variation of the public key authentication method. With certificates, each user's (or host's) public key is signed by another key, known as the certificate authority (CA). The same CA can be used to sign multiple user or host keys. The user or the host can then ... | How to generate a certificate file which to be used with ssh config? |
1,444,351,101,000 |
I want to log into a linux server using two sequential bastion hosts.
My .ssh/config file looks something like this:
Host *
User username0
Host hostname0
Hostname foo
Host hostname1
Hostname bar
Port 0
ProxyCommand ssh -W %h:%p hostname0
Host hostname2
User username2
Hostname bat
Port 1
ProxyCommand ... |
Use different order of the Host blocks. The Host * matches everything and ssh_config does not overwrite already stored entries:
Host hostname0
Hostname foo
Host hostname1
Hostname bar
Port 0
ProxyCommand ssh -W %h:%p hostname0
Host hostname2
User username2
Hostname bat
Port 1
ProxyCommand ssh -W %h:%p ... | SSH with a bastion host and different usernames |
1,444,351,101,000 |
In the environment I work in, we use tunnels to SSH to various servers. For example, I'll 'ssh -p XXXXX username@localhost' to reach the server.
If the port was always the same, I could do this, and I'd be done:
Host somehost
User bryan
Hostname localhost
Port 12345
ProxyCommand ssh -p 2218 [email protected... |
It is not possible to write a script in the configuration file to pull a variable for port number.
But you can write a bash function to get the port for you and place it into the correct place. For example place the following to the ~/.bashrc:
function ssh-dynamic() {
PORT=`sh get_port_for_somehost.sh`
exec ssh -p... | .ssh/config ProxyCommand with a variable port |
1,444,351,101,000 |
Testing out the SSH Match Exec feature. I have this minimal ~/.ssh/config:
Match Exec echo
ServerAliveInterval 60
and I am running
ssh localhost
I get
Unable to execute 'echo': No such file or directory
This is true regardless of whether I use a full path or not, or using quotes whether double or single. I trie... |
You should set the SHELL environment variable to the full path of your shell, not simply to bash or zsh.
Try:
SHELL=/bin/bash ssh user@host
| Match Exec failing to execute anything |
1,444,351,101,000 |
I want to run a command automatically after I connect to another machine via ssh, without the ssh session being closed automatically.
After searching the internet I found some solutions but none of them work the way I need.
ssh bla@bla "ls"
This runs the ls command on the remote machine, shows me the output and close... |
ssh bla@bla "ls ; bash"
This doesn't disconnect after running ls, but I don't get a full terminal interface, just some bare bones command line that doesn't show the me@machine:~$ thing.
If you specify a command (e.g. ls ; bash above) the SSH server will not provide a pseudo-terminal. You have observed exactly this.... | How do I run a command after a ssh connection, without disconnecting? |
1,444,351,101,000 |
I want to use .ssh/config to connect to a host through a gateway. I don't want to set up an RSA key and have to use password. I have previously done this kind of hopping without password. Now trying to do it with password.
A direct command that works for me is:
sshpass -p mypassword ssh -o ProxyCommand="ssh gateway -W... |
I don't think your configuration is the same as that one-liner, it looks more like this:
ssh -o ProxyCommand='sshpass -p mypassword ssh -o ProxyCommand="ssh gateway -W %h:%p" h_act' myusername@myip
i.e. you have the sshpass running inside a ProxyCommand.
But I don't think that will work, sshpass wraps the ssh client... | Multihop with sshpass |
1,444,351,101,000 |
To run interactive programs remotely one should use ssh -t <host>. But this -t option also has drawbacks so it's not good to use it on non-interactive programs.
My problem is: I have several machines. Some of them are for interactive programs and others for non-interactive ones. So I must remember exactly which ones n... |
The option you're looking for is RequestTTY. From the ssh_config man page:
RequestTTY
Specifies whether to request a pseudo-tty for the session. The argument may be one of: `no' (never request a TTY), `yes' (always request a TTY when standard input is a TTY), `force' (always request a TTY) or `auto' (request a TTY ... | Force PTY allocation in ssh_config |
1,444,351,101,000 |
How can I run/tweak this command and while using ForceCommand to give this user their shell?
Client Command
(cat ./sudoPassword ./someCommandInput) | ssh user@ip "sudo -Sp '' someCommand"
Server sshd_config
ForceCommand /bin/bash
The behind the scenes restriction is that ForceCommand needs to be the mechanism that giv... |
Use a wrapper script as the ForceCommand. Something like this script (say, saved at /usr/local/bin/myshell):
#! /bin/bash
if [[ -n $SSH_ORIGINAL_COMMAND ]] # command given, so run it
then
exec /bin/bash -c "$SSH_ORIGINAL_COMMAND"
else # no command, so interactive login shell
exec bash -il
fi
In action:
% gre... | SSH ForceCommand for shell while keeping regular login and remote command execution possible |
1,444,351,101,000 |
How can I have rules for a whole domain and also create aliases with rules for each of the subdomains without duplicating all the ruleset?
In other words, why is it that in the following example boomerang is not used as the default user when I try to ssh into mega.micro.ws by invoking ssh mega? And is there a correct ... |
Normally the configuration is parsed in a single pass. First all sections are checked against your input and all settings are gathered, and only after that's done, the HostName setting is actually applied.
To achieve what you want, instead of a Host section you'll need a Match section:
Match final host *.micro.ws
... | Nested settings in ssh config for domains and aliased subdomains |
1,444,351,101,000 |
Our accounts in our lab are all mounted over NFS and are accessible over all the systems in a subnet. So, effectively we can ssh into any of the machines in the subnet and continue our work. The problem is that the machines come up or go down randomly because of people accidently turning it off etc. To find running ma... |
The Host directive can take multiple hosts, for example:
Host *.domain.tld specific-host.tld 10.*.*.*
User foo
Port 2222
This would set user and port for all hosts matching the star pattern,
the explicit host specific-host.tld, or, assuming you type IP
numbers, any host whose first IPv4 byte is 10. Then you can add H... | Use a dynamically obtained hostname with an ssh config entry |
1,444,351,101,000 |
I'm trying to set up public key authentication on a CentOS 7.3 guest, using WSL.
When trying to copy the public key using ssh-copy-id, it's rejected, saying it already exists on the VM. This is not the case, since it's a fresh install, and there isn't even an .ssh directory in /root.
After searching around, wrong file... |
Verbose is not needed. INFO log level is enough, as it is already fixed in the upstream repository.
Commit message explains it pretty much:
the LogLevel is set to 'None' we'll not get the
Permission Denied we're looking for.
This is not a problem in default configuration (since default value is INFO as per manual ... | Why does ssh-copy-id need verbose LogLevel to work in this case? |
1,444,351,101,000 |
I am logged in in my local PC (Fedora 24) as rperez. From this PC I needed to connect to a remote server through sshfs so I generated a private/public key by running ssh-keygen. Using the following command I am able to connect to the server without any problem:
sshfs rperez@server_ip:/home/rperez -p 2051 ~/dev -o auto... |
Running the ssh in debug mode usually uncovers various problems. Usually permissions. In this case
Bad owner or permissions on /home/rperez/.ssh/config
means that the configuration file can not be writeable by others and therefore
chmod go-w /home/rperez/.ssh/config
should fix the problem for you.
| Can not connect through sshfs because a wrong configuration at ~/.ssh/config file |
1,444,351,101,000 |
So my university supplied access to a server with backslashes, like this:
ssh portoalegre\\[email protected]
and I decided to copy my public key there to be more secure (and not having to type the password every time). This works fine! However ... I then decided to set an entry in ~/.ssh/config so I could just login ... |
The \\ in your SSH command really represent a single \ (try echo portoalegre\\[email protected] and see what that displays). So the first thing to try is to use a single backslash in your SSH config:
Host university
Hostname university.server.br
User portoalegre\15280433
| How to use backslash in user on ~/.ssh/config |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.