date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,415,183,595,000
Currently playing around with the dialog command and I have noticed that when I press Shift-Tab or press ESC, the execution immediately exits and I am back on the command prompt. Since this is not a signal, I can't trap and discard it, so how would I "trap"/capture this escape and discard it so that the only way to ex...
Shift+Tab is usually a back-tab on terminals that you are likely to use. The manual page section KEY BINDINGS comments that dialog's key bindings can be curses keys It may be any of the names derived from curses.h, e.g., "HELP" from "KEY_HELP". and in the section Built-in Bindings explains that the --trace option ca...
How to capture/ignore ESC during the execution of dialog?
1,415,183,595,000
Is it possible for a2ps to interpret the ANSI escape codes ? $ echo -e "\033[31mHello\e[0m World" | ./bin/a2ps -o output.ps if not, do you know another tool that would do this task ?
aha - Ansi HTML Adapter Converts ANSI escape sequences of a unix terminal to HTML code. aha Git repo Then you just need a tool to make HTML to PS like html2ps.
printing ansi colors/escape codes with a2ps
1,415,183,595,000
I'm able to get the desired output by running this command on terminal: top -bn 1 | grep "^ " | awk '{ printf("%-8s %-8s %-8s %-8s %-8s %-8s %-8s\n", $1, $2, $9, $10, $6, $11, $12); }' | head -n 6 And I'm able to SSH twice and get the hostname by running this on terminal: ssh 192.168.5.209 "ssh 192.168.5.210 exec \"h...
grep, awk, and head can be merged and run locally ssh 192.168.5.209 "ssh 192.168.5.210 top -bn 1 " | awk '/^ / { printf("%-8s %-8s %-8s %-8s %-8s %-8s %-8s\n", $1, $2, $9, $10, $6, $11, $12); c++ ; if (c==6) exit ;} where /^ / search for line starting with a space c++ ; if (c==6) exit ; will exit awk after 6 line...
SSH twice and run command, escaping character?
1,415,183,595,000
I want to delete anything that follows a % to the end of the line. Using cat /tmp/foo.txt | sed 's/%.*$//' works great with one exception: I want to ignore any escaped percent signs \%. So with the following file saved as /tmp/foo.txt abcd %123 xyz \%xyz xyz \%xyz %123 the output I want is abcd xyz \%xyz xyz \%xy...
You need to look at the character before the percent. sed 's/\([^\\]\)%.*/\1/' If the previous character is not a backslash, keep that char and remove the rest. This answer assumes that the % does not appear at the beginning of the line. If it does, then we need to check for it sed 's/\(^\|[^\\]\)%.*/\1/'
sed exception handling of escaped characters
1,415,183,595,000
I have a JSON file that looks like: { ... "python.pythonPath": "", "python.defaultInterpreterPath": "", ... } I want to update it to { ... "python.pythonPath": "/Users/user/.local/share/virtualenvs/venv-Qxxxxxx9/bin/python", "python.defaultInterpreterPath": "/Users/user/.local/share/virtualenvs/venv-Qxxxxxx9/bin/pyth...
I was not able to get the sed command working. I however found a way to run a Python script inside bash that did the job for me. If anyone is interested: export new_path="/Users/user/.local/share/virtualenvs/venv-Qxxxxx9/bin/python" python3 - << EOF import json import os with open('settings.json', mode='r+') as file...
Use "sed" to replace file containing "" and \
1,415,183,595,000
I use the kitty terminal emulator for my day to day development, and I learned that it has these custom escape sequences for fancy underlines. I really wanted to get them working in vim, and after some vimrc tweaks, they started showing up. However, whenever I'm in a tmux session, the codes suddenly stop working. I've...
tmux is a terminal emulator. The control sequences that kitty understands are irrelevant to applications that are talking to a tmux terminal. tmux does not understand them. Your applications running under tmux have no direct connection to a kitty-emulated terminal. For such a thing to work, the terminal emulator pa...
Using extended escape codes in tmux
1,415,183,595,000
I have a shell script I am trying to get working. I need the output to be a certain way and I know I'm just not escaping the characters correctly. script: #!/bin/bash set -x DATE=$(date +%Y-%m-%d-%M) ELEMENTS="ele1,ele2,ele3" TOPIC="dogs cats" FILE="./$DATE.csv" COMMAND="python /home/script.py" $COMMAND $ELEMENTS "$TO...
Change TOPIC="dogs cats" to TOPIC='"dogs cats"' to have " embedded inside the variable.
Double quotes issue in bash script
1,415,183,595,000
When I use cat Variables/user-extensions.js | sed -e 's/css/XXX/' on an input file of the form storedVars["css_body"] = "css=body"; storedVars["css_main"] = "css=main"; I see output such as storedVars["XXX_body"] = "css=body"; storedVars["XXX_main"] = "css=main"; However if I add > x and then use vi to edit the x ...
The problem is in using my aliased cat which adds the special characters. Instead of cat Variables/user-extensions.js | sed -e 's/css/XXX/' > x use sed 's/css/XXX/' Variables/user-extensions.js > x
Why is vi (but not cat) showing ^[[31m[^[[m^[[31m" after I use sed and output to a file I then edit? [closed]
1,415,183,595,000
I am trying to assign the result of a sed command to a variable in bash, but I am unable to escape everything corrrectly (probably just due to my lack of knowledge in bash), I have tried: hash_in_podfile=$( sed -rn 's/^ *pod [\'\"]XXX["\'],.*:commit *=> *["\']([^\'"]*)["\'].*$/\1/p' ${PODS_PODFILE_DIR_PATH}/Podfile ) ...
There are two issues in your script: The sh on macOS is a very old version of the bash shell, and it has a bug that stops you from using unbalanced quotes in here-documents in command substitutions: $ a=$( cat <<'END' > " > END > ) > sh: unexpected EOF while looking for matching `"' (I had to press Ctrl+D after the ...
Assign sed command correctly
1,415,183,595,000
I suspect the following has been answered already but I don't know the terminology for the issue I'm having well enough to find an existing answer. I'm working on a command to go through a list of files and output on each line the filename followed by the count of lines that start with P. I've gotten this far: find -t...
Better not embed data (filenames) directly in code (the shell scriptlet). Instead pass the filename as an argument to the shell you have xargs run: find -type f | xargs -I % \ sh -c '{ echo "$1"; grep -c -P "^P \d+" "$1"; } | tr "\n" ","; echo' sh % Also you should be able to use grep -c instead of grep | wc -l, it...
Handle parentheses in this xargs multi-command
1,415,183,595,000
I have a string that is a path: /tmp/something I need to escape the forward slashes with backslashes: \/tmp\/something How can I do this? Maybe sed? Please point me in the right direction.
You can do it with Bash's own variable manipulation methods (parameter expansion), though the syntax is fairly monstrous: $ string='/tmp/something' $ escapedstring="${string//\//\\\/}" $ printf '%s\n' "$escapedstring" \/tmp\/something To explain this further, in bash ${var//xxx/yyy} means "take variable var and ...
bash insert backslash for every slash in string
1,415,183,595,000
Let's say I want to search a file for a string that begins with a dash, say "-something": grep "-something" filename.txt This throws an error, however, because grep and other executables, as well as built-ins, all want to treat this as a command-line switch that they don't recognize. Is there a way to prevent this f...
For grep use -e to mark regex patterns: grep -e "-something" filename.txt For general built-ins use --, in many utilities it marks "end of options" (but not in GNU grep).
Stop executables and built-ins from interpreting a string argument starting with - as a switch? [duplicate]
1,415,183,595,000
It took me 10 hours of searching the net, and testing techniques to get the results that worked on any shell (#!/bin/sh). In BASH this is relatively simple, because read can be told how many characters are to be grabbed, and if a delimiter is found it will not wait to exit. stty -icanon -echo; echo -en "\033[6n"; read...
Note: unlike the wrongly copied and continually upvoted answer provided (points scoring?), the following script IS NON-BLOCKING, and does not care what length returned input may be. IE it will work with ANY screen size. With SH it is more complex, and I was unable to find enhanced command line version of the built-...
How to get the results from "\033[6n" in an sh script
1,415,183,595,000
I have a shell script part of which is the following JSON: curl --request POST \ --url 'https://'$jira_instance'.atlassian.net/rest/api/2/field/'$field_ID'/context/'$context_ID'/option' \ --user $jira_user'@whatever.com:'$api_token \ --header 'Accept: application/json' \ --header 'Content-Type: application/jso...
Generally, to properly quote a variable within single quotes in Bash, use '"$var"' (single quote followed by double quote). The first single quote ends the single-quoted string, then there's the double-quoted variable, and the second single quote restarts the single-quoted string. Without the double-quotes, the parame...
Issue with double quotes inside double quotes in JSON
1,415,183,595,000
I am trying to echo I say "Hello, World!" with bash -c. This is (some of) what I have tried: $ bash -c "echo I say \"Hello, World"'!'"\"" $ bash -c "echo I say "'"'"Hello, World"'!'"\"" $ bash -c "echo I say """Hello, World"""'!' $ bash -c $'echo I say \"Hello, World!\"' $ bash -c 'echo I say "Hello, World!"' They al...
The problem lies in the fact that you have nested quotes, which makes quoting somewhat involved. Since you don't have a "comprehensive" quote around your arguments to echo, all your attempts (except for your 3rd attempt(1)) are actually passing three arguments to echo, which are all subject to quote removal: I say He...
Show quotes with echo inside bash -c
1,596,129,203,000
This feels like an incredibly simple task, but I can't get it to work. I want to put the first 13 files in a directory into a .zip archive. The obvious way to do this is zip first13.zip $(ls | head -n 13) But this fails because some of the filenames--which I can't change for stupid institutional reasons--have spa...
Since you are using zsh, you should be able to use a glob qualifier of the form [m,n] to select a range of matches - avoiding the head pipeline (and its implicit whitespace splitting) altogether: zip first13.zip ./*([1,13]) See man zshexpn for further details
How do I pass filenames with spaces in them to `zip`?
1,596,129,203,000
I am using \0n escape sequence with echo -e and printf where n is the octal value of the ASCII character to be printed. When i used the statement echo -e "\0101" the shell is printing character A but when i use printf "\0101" the shell is printing 1 which is the Least significant bit of the octal number i provided but...
From man echo1: \0NNN byte with octal value NNN (1 to 3 digits) From man printf1: \NNN byte with octal value NNN (1 to 3 digits) The two commands are not accepting the same format for octal sequences. You can easily check that their actual output is quite different: $ echo -en "\0101" | od -A n -t o1 101 echo...
printf and echo -e are giving different results
1,596,129,203,000
I am trying to understand what the second echo statement does exactly (it's an existing script).. echo "Triggering report.. " curl -s -X POST "http://aaa.bbb" echo -e \ '\ ' I read that -e enables backslash escaping. However, not sure why there is one backslash outside, and also why there is a backslash alone inside ...
That second echo is equivalent to the following more portable command: printf ' \\\n\n' This outputs a space, a backslash, and two literal newline characters. As a comparison, the echo command outputs these characters by outputting an escaped space together with a literal backslash and a literal newline character. T...
I am trying to understand what a particular echo statement does
1,596,129,203,000
I have a 'typescript' file that if i cat -v I get the following within the output: M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-b...
Assuming that M- is meta and ^ is control, the sequence M-b M-^T M-^@ represents hex e4 94 80. The character ─ you gave is unicode U2500, "BOX DRAWINGS LIGHT HORIZONTAL". If you line up the bit patterns, you get something like 1110 0100 1001 0100 1000 0000 = e4 94 80 0 0100 1 0100 00 0000 = 2500 So this s...
What is this sequence of control characters (M-bM-^TM-^@) (dashes)? How can I transform these? [closed]
1,596,129,203,000
I found that groff uses different ways to indicate bold text for the utf8 output format. On FreeBSD 14, groff emits escape codes for a terminal (ESC, [1m): $ printf ".Dd today\n.Sh NAME\n" | groff -mandoc -Tutf8 | od -c 0000000 \n 033 [ 1 m N A M E 033 [ 0 m \n [...] On Linux (debian Bookworm) ...
Debian Bookworm configures groff 1.22 for the old backspace-overwrite behavior you see there, and documents it in their patched grotty manual page along with how to revert to the newer SGR (\e[1m-like) behavior: printf ".Dd today\n.Sh NAME\n" | GROFF_SGR=y groff -mandoc -Tutf8 It seems that the given configuration an...
groff -mandoc creating "ESC[1m" versus overstriking with backspace for bold text
1,596,129,203,000
Is it possible to get dialog command, example: dialog --title "HELLO" --yesno "Are you sure?" 6 30 into a file with all ANSI escape codes, so it can be printed later? You can redirect the dialog into a file to get the output but you can't interact with the page, so it may be hard to exit.
You can use script: script -q -c 'dialog --title "HELLO" --yesno "Are you sure?" 6 30' dialog will run interactively, so you’ll be able to exit easily, and even track screen changes made in response to user input if you with (script supports timestamps, which can be useful here). The output will be stored in a file n...
Saving ANSI codes from dialog command into a file
1,596,129,203,000
I'm writing a bash script to find all the images in the folder and find if they have corrupt endings with ImageMagick. This is the command I'm trying to automate: identify -verbose *.jpg 2>&1 | grep "Corrupt" | egrep -o "([\`].*[\'])" The issue I'm having is with storing the identify command into a variable. There ar...
What you are probably looking for is a way of identifying corrupt images. It's easy to query the identify tool for its exit-status to see whether it managed to identify the image file or not. #!/bin/sh for name in *.jpg; do if identify -regard-warnings -- "$name" >/dev/null 2>&1; then printf 'Ok: %s\n' "...
Bash script escaping quotes
1,596,129,203,000
I have a directory with some .flac files: [test]$ ls 'test file (with $ign & parentheses).flac' 'test file with spaces.flac' I want to run an ffmpeg test command on those files, i used find with -exec argument to achieve this: find ./ -type f -iregex '.*\.flac' -exec sh -c 'ffmtest=$(ffmpeg -v error -i "{}" -f n...
The {} is replaced literally by the filename, so put it somewhere that it doesn't get parsed specially. Since you're already using sh -c, the argument position seems ideal: find ./ -type f -iregex '.*\.flac' -exec sh -c 'ffmtest=$(ffmpeg -v error -i "$1" -f null - 2>&1);if [ -n "$ffmtest" ];then echo -e "$1\n" $ffmt...
use find -exec with a filename containing a dollar sign ($) [duplicate]
1,596,129,203,000
Do terminals ignore superfluous escape sequences silently? #!/bin/sh printf "\033[?25l" printf "\033[?25l" # superfluous printf "\033[31m" printf "\033[31m" # superfluous printf "Red Text\n" sleep 1 printf "\033[0m" printf "\033[?25h"
Yes, they do. You might be familiar with certain document formats, e.g. HTML where opening and closing tags need to correspond to each other. E.g. this is okay: <font style="color:red"><font style="color:red">foobar</font></font> but this is not, since the tags are not balanced: <font style="color:red"><font style="c...
Do terminals ignore superfluous escape sequences silently?
1,596,129,203,000
I'm outputting an echo -ne command to a file in my set-up script for a usb mouse HID. Here is the script, which is run as root through /etc/rc.local at bootup: #accidentally had a newline here <--- #!/bin/bash cd /sys/kernel/config/usb_gadget/ mkdir -p isticktoit cd isticktoit echo 0x1d6b > idVendor # Linux Found...
The behaviour of echo is notoriously unportable. Your script probably runs with some other shell when it doesn't work. (You're not running sh scriptname, are you?) See, e.g. how echo differs in Bash and Dash: $ bash -c 'echo -ne \\x41\\x42\\x43\\x0a' ABC $ dash -c 'echo -ne \\x41\\x42\\x43\\x0a' -ne \x41\x42\x43\x0a...
Correctly Escape echo -ne [closed]
1,596,129,203,000
I'm trying to use this line in a bash script to update my cron jobs: (sudo crontab -l ; echo "0 6 1-7 * * [ $(/usr/bin/date +\%u) == 7 ] && sh $script_path > $log_path") | sort - | uniq - | sudo crontab - Prior to this, $script_path and $log_path have been defined. I know this works in general. I just have one hang...
You may escape each problematic character with \ (see Hunter.S.Thompson's answer) or just use single quotes, the enclosed string being written as is: (sudo crontab -l ; echo '0 6 1-7 * * [ $(/usr/bin/date +\%u) == 7 ] && sh '"$script_path > $log_path") | sort -u | sudo crontab - I personally tend to avoid escaping ch...
Another Bash string escape question (using echo)
1,596,129,203,000
My source of question is the answer here on this link, plus some extra things UPDATE I understand the first command i.e grep \\[[a-z\|1-9]*\\] file but I don't understand the output of second command i.e grep \[[a-z\|1-9]*\] file. Now, I just want to understand how the output of second command is constructed especiall...
Lets walk slowly. If there is a file with this content (in just one line to make it easier to show): $ cat infile list[1]; i[ab1]; var[1] [1]var [1]var[2] a A simple grep --color a will show in red all the a's. (As this site does allow the control of colors : Assume that bold is red): $ grep --color a infile list...
Understanding Escaping
1,596,129,203,000
I recently tweaked a bit my PS1. The code as follows: PS1='$(if [[ $? != 0 ]]; then echo " \e[91m\e[0m"; fi) \u $(assemble_prompt)$ ' The missing char is from nerd-fonts and doesn't matter in my question (as well as assemble_prompt function). The problem I encountered is a broken PS1 when I shrink terminal window si...
You probably want to enclose the terminal control codes in \[...\] to tell Bash that they aren't actually printing characters. Otherwise they will confuse the shell when tries to count how wide the prompt is. So use "\[\e[91m\]xxx\[\e[0m\]". From the manual: \[ Begin a sequence of non-printing characters. This c...
Prompt customization problem with if clause
1,596,129,203,000
I have learned about formatting options used in shell scripting, which go like this: \033[37:40mAnyText\033[0m Now I want to echo some text like this: echo -e "SomeText \033[5;31;47mMoreText\033[0m" The integer 5 is for blinking. The other formatting works, but not the blinking -- why?
This is a terminal independent way of enabling the blinking attribute. If it doesn't work then either you've mis-set your terminal type, it's not enabled in the terminal characteristics, or it's simply not supported: tput blink echo hello, world tput sgr0 The terminfo database is well worth perusing (not bedtime read...
Create blinking text with echo and escape characters [duplicate]
1,596,129,203,000
How can the following list of commands can be quoted separately? s="cp mkdir [[ mv rm" quoted_s= ???? This should be the output of echo $quoted_s: cp mkdir \[\[ mv rm Using ${(q)s} or ${(qq)s} quotes them together: $...
In this case, you could use the b expansion flag. From info zsh flag or man zshexpn: b Quote with backslashes only characters that are special to pat‐ tern matching. So given ~ % print -r -- $s cp mkdir [[ mv rm then ~ % print -r -- ${(b)s} cp mkdir \[\[ mv rm More generally, you could split on ...
zsh: How can I escape each word separately?
1,596,129,203,000
I am learning ECMA-48 and I see a lot of notes about 7 bit and 8 bit environments for control functions. For example: NOTE LS0 is used in 8-bit environments only; in 7-bit environments SHIFT-IN (SI) is used instead. Could anyone explain the difference between them and give real examples when each of them is used.
Very early printers might have two colours on the ribbon, like mechanical typewriters did. SI and SO switched between the optional colour and the normal colour. Note that this is not the same usage as the shift key! Early printers and terminals (I'll call them all just terminals from now on) used a 7-bit ASCII code....
What are 7 bit / 8 bit environments for control functions according to ISO/IEC 6429:1992?
1,596,129,203,000
It is possible to pass resources to X applications in command-line by appending them with -xrm parameters. So, if I want Xmessage background to be grey, I can issue xmessage Hi -xrm "xmessage*background: grey". Things get tricky if I want to modify event translations. On my .Xresouces, this Xmessage*Translations:#over...
You need to put in single quotes : xmessage Hi -xrm 'xmessage*Translations:#override\ <Key>F10:exit(-1) \n\ <Key>q:exit(-1)' Otherwise, newlines get lost.
Trouble passing Translations resource to -xrm because of newlines
1,596,129,203,000
I am trying to take a filename from the ~/Pictures folder and supply it as an argument for the nomacs command. The filename contains some spaces, so I am using Bash substitution to escape spaces (I also want to take last file in the folder). The code: names=$(\ls ~/Pictures * | tac) SAVEIFS=$IFS IFS=$'\n' names=($na...
From what I gather from your script, you're reversing the output of ls and selecting the first item. Here's a different way to do that with bash: files=(~/Pictures/*) nomacs "${files[-1]}" This fills an array with the glob expansion of ~/Pictures/* then passes the last element to the nomacs program.
Providing argument to a command after substitution
1,596,129,203,000
I'm using the jq tool to handle some JSON in bash. Just one problem, while using this line: PB_ACL="acl="`echo $IMGREQ | jq -r'.data.acl'` Result: echo $PB_ACL // acl= The expected value jq has to filter out is: "acl":"public-read" But it's not working now. I think it has to to with the dash (-) symbol. How do...
Missed a space: PB_ACL="acl="`echo $IMGREQ | jq -r '.data.acl'` ^
How to escape an input string in Bash [closed]
1,596,129,203,000
I have a long command and I just want to use alias to shorten it. But the command contains single quotes and exclamation marks. The origin command is ldapsearch -x -H ... -w 'abc!123'. I tried alias search='ldapsearch -x -H ... -w \'abc!123\'' or alias search="ldapsearch -x -H ... -w 'abc!123'" and so on. But none of ...
! is only a problem for history expansion. History expansion only happens in interactive shells (when not disabled altogether by the user like I do) and in bash (like in zsh, but contrary to csh where both history expansion and aliases come from) happens before alias expansion and is not done again after aliases are e...
How to escape both single quotes and exclamation marks in bash
1,596,129,203,000
I have a script that finds some directories and then copies their content to another directory. now the problem is that some of the found directories need to have brackets in their naming and they look something like this: /directory/with/[brackets] and cp says that there is no such file or directory when it tries to ...
You basically have two options: Escape using quotes: cp -r "/directory/with/[brackets]"/* /some/other/directory or cp -r '/directory/with/[brackets]'/* /some/other/directory Escape using backslashes: cp -r /directory/with/\[brackets\]/* /some/other/directory
How do I escape opening and closing brackets [] to use with cp command?
1,596,129,203,000
I'm trying to add a history fuzzyfind hotkey to my bash shell. However, my intended command gets cut in the middle: [april@Capybara-2:~]$ cat ~/.bashrc bind "\"\C-r\": \"\$(history | fzf | awk '{\$1=\"\"; print substr(\$0,2)}')\"" [april@Capybara-2:~]$ $(history | fzf | awk '{$1=""; (The second line is the result w...
It's quoting hell. You have the command in double quotes, so the \"\" becomes "", so for Readline, the command looks like: bind "\C-r": "$(history | fzf | awk '{$1 = ""; .... See the problem? The string started at "$( is ended by the first double quote in "";, I'm not sure how exactly string concatenation works for R...
Problem with bash builtin bind and escaping
1,596,129,203,000
I want to make a bash alias of the following command, which works typed out on the command line but all my attempts at making an alias have failed. My only diagnosis is that all those nested quotes and the loop are scary and I don't know how to handle them. sudo ss -x src "*/tmp/.X11-unix/*" | grep -Eo "[0-9]+\s*$" | ...
For anything more complicated than, say, adding an option to some command, use shell functions rather than aliases. Here's a function, mything, that you would define in the same place where you would ordinarily define aliases, which runs the command s that you show: mything () { sudo ss -x src "*/tmp/.X11-unix/*" ...
Bash alias with a loop, a sudo, pipes, flags, single quotes and double quotes
1,596,129,203,000
I have the following Problem, I need an environment variable that contains globbing characters as clear text, and I can't seem to escape them. Escaping with backslash works, but for some reason the backslash is still part of the string." Disabling GLOB_SUBST resolves the problem, but I´d like to avoid that. I used the...
In the first case, you assign the string * to the variable, and since globsubst is enabled, the unquoted expansion $test is subject to globbing (as in a POSIX shell). In the second case, you assign the string \*, but it's not expanded as a glob since the backslash escapes the asterisk. (Otherwise zsh would complain th...
Properly escaping asterisk/glob in (z)sh script
1,596,129,203,000
In my current project, I am trying to take the output from git branch -r to an array in zsh, as follows: % all_branches = ("${(@f)$(git branch -r)}") However, when I run this command, I get the following error message on the terminal: zsh: bad pattern: ( origin/Backplane-Broken-Links I'm inferring that zsh is taki...
array assignment syntax in zsh (like in bash which borrowed that syntax from zsh) is: array=( value1 value2 value3...) There can't be whitespace on either side of = (though there can be (space, tab or newline) inside the (...) which are used to delimit the words as usual, and those words making up the array members)...
Escape slashes when sending command output to an array [duplicate]
1,596,129,203,000
I have another question about ANSI Art. The problem is this file https://16colo.rs/pack/lgcy-003/hayn9-smaller.ans It have "à" character (the women in ANSI Art have it inside medalion on her neck). And just before that, there is this sequence of ANSI Escape codes: [0;5;30mà In Difference between ANSI art and Linux T...
Found the answer in blocktronics/moebius ANSI Art editor source code on GitHub. The blink flag change bold only for the background. And normal bold change bold for color. This can be found in this file app/libtextmode/ansi.js@0ff8f66#L203.
Problematic [0;5;30m ANSI Code in ANSI Art
1,596,129,203,000
Many non alpha-numeric characters appear as jumbled mess when using less and man. Currently, I'm using zsh but the same problem happens in bash and sh. The problem also appears in both the st and termite terminal emulators. man grep produces: How can i fix this? env -i TERM=$TERM PATH=/usr/bin:/bin HOME=/none man gre...
Since the problem disappears with a minimal environment, it's caused by an environment variable. It turns out to be your LESS_TERMCAP settings. You've set them to sequences beginning with [. They're missing the initial escape character. csi=$(printf '\033[') export LESS_TERMCAP_mb="${csi}1;31m" …
Extra characters appear in `less`
1,596,129,203,000
i have command like this date -d @$(date -d 'Sat, 08 Aug 2020 00:00:00' "+%s") +'%Y-%m-%d' which output this 2020-08-08 So i want to use thins in bash scrip, i created this (this is just part of realy big script) Date1=$1 date -d @$(date -d $Date1 "+%s") +'%Y-%m-%d' But when i try to run like this ./test.sh "Sat,...
Wrap your $Date1 inside the quotes and it should work: date -d @$(date -d "$Date1" "+%s") +'%Y-%m-%d' See also When is double-quoting necessary?
Bash scrip passing argument in quotes
1,596,129,203,000
I am doing some automation with shell scripting and I am having trouble running a python script in which its' path has spaces. Forgive me if I made any mistakes or bad practices in the code, I just started learning yesterday :). Here is the code: # grabs root directory from the script path script_path="$( cd "$(dirnam...
Short answer: See BashFAQ #50: I'm trying to put a command in a variable, but the complex cases always fail! Long answer: Don't try to embed shell syntax (like quotes and escapes) in variables; variables are for data, not syntax. Instead, just put double-quotes around variable references (i.e. put the quotes around th...
Issue running a python script in shell script that has spaces to the python script
1,596,129,203,000
Context: I use zsh and use vi editing mode. To go up in the history instead of pressing ESC to go to the normal mode and pressing k, I press alt+k which sends the esc character and sends k afterwords (as per my understanding) Problem: It works fine until I start a ssh session, even after closing the session it doesn't...
There is an old way of signalling "meta", which assumes that you are using a 7-bit character set and that it is free to fiddle with the high bits of characters. It doesn't really work well with 8-bit character sets let alone UTF-8, producing characters confusing to the uninitiated as you have seen. Only some terminal ...
st terminal + shell vi mode
1,596,129,203,000
I have a script which i want to auto-login inside a mysql database. The problem is when the password has special characters, here an example: Password file contains: password=$AES-256$VlQ==$+rZfd6ntjZdyD0= And this is the script: pass=$(cat password_file | grep password | cut -d"=" -f2) mysql -uroot -p$pass How could...
You can try this with GNU grep: grep -Po "(?<=^password=).*" file With sed grep "^password" file | sed 's/[^=]*=//' With awk: awk -F'password=' '{ print $2 }'
Scripting login to mysql with a string with special characters
1,596,129,203,000
I have been looking for this question everywhere, but I didn't find it and there doesn't seem to be any kind of answer yet to my current problem, which, frankly, doesn't even make sense. So, what I want to do is escape the question mark ? in my variable declaration. Obviously writing var=? won't do it. Of course, you...
You should quote the variable in your echo command: $ var=? $ echo "$var" ?
Cannot escape '?' character in variables (unix)
1,596,129,203,000
I am trying to use a newline in bash. I found that I need ANSI C quoting for that (i.e. $'\n'), but this often does not work for me. So I am wondering what I am doing wrong. # This works >> echo $'a\nb\nc' a b c # This doesn't >> A=$'a\nb\nc' >> echo $A a b c # Also, this does not work >> A="a b c" >> echo ${A// ...
Because you've not quoted the variable in: echo $A it is subject to splitting and globbing. The first step is the expansion of the variable's contents: echo a $'\n' b $'\n' c -- where the $'\n' bits represent actual newlines. Then, the various pieces are split on $IFS, resulting in: echo a b c Then, since there are no...
ANSI C quoting for tab and newline sometimes does not work
1,596,129,203,000
I have a pretty big json file and I would like to add the escape character in front of all quotation marks in it. For example I want to change: "CaptureDuration":0 to \"CaptureDuration\":0. I tried to substitute all " with \" in sed and vim but I guess due to the special type of the escape character it wasn't working...
Use sed and you needed to escape \ as it's special character: sed 's/"/\\"/g' infile
Add escape character in front of all quotation marks in a file
1,511,064,482,000
I’m trying to create a ls-like function. I started with this alias, which works fine: alias l="/usr/bin/ls -lF --color=always | tr -s ' ' | cut -d ' ' -f 9-" However, converting it to a function results in no colors: l() { local _c= [ -t 1 ] && _c=--color=always /usr/bin/ls -lF $_c "$@" | tr -s ' ' | cut ...
Are you sure you haven't got an l alias that is either interfering with the function definition or being used before the function: aliases take precedence over functions. And are expanded even for a function definition.
escape sequence behaving differently in function
1,511,064,482,000
I want to backslash a variable automatically so that the end users don't need to type the backslashes for a Perl regex string replacement. API_URI="http://something/api" FIND="(API_URI)(.*?[\=])(.*?[\'](.*?[\']))" REPLACE="\\1\\2 \'$API_URI\'" perl -pi -e "s/${FIND}/${REPLACE}/" file.ext
By all means use Perl if you want to, but doesn't this sed do the trick? echo "$API_URI" | sed 's/\//\\\//g' http:\/\/something\/api Or... in straight Bash: echo "${API_URI//\//\\/}" http:\/\/something\/api
How to backslash a dynamic string in bash
1,511,064,482,000
I want to remap my F9 key to the dollar sign ($) symbol. So I ran this command bind '"\e[20": "$"' Now whenever I type the F9 key, instead of getting just $ I get $~ Why is the extra tilde there and how can I get rid of it?
Try this: bind '"\e[20~": "$"' To determine character sequence for a key press, Press Ctrl+v and press the key for which you want to get the character sequence. Example: For key F9, I get ^[[20~ where ^[ is Esc key and remaining sequence is for F9.
Why does my binded key result in an extra tilde?
1,511,064,482,000
My text in vim looks like, i am one line i come in next line i come after a tab space Can the above text be converted like this, i am one line\ni come in next line\n\ti come after a tab space
From my understanding of your question you want to convert newlines to the literal sequence backslash followed by n and convert tabs to the literal sequence backslash followed by t. For replacing the tab character, sure, no problem, it's the same as normal string replacement. Try this: :%s/\t/\\t/ Note: the recogniti...
In vi, convert invisible characters into escape sequences?
1,511,064,482,000
I have some shortcut keys defined in iTerm, and I use them for key-mappings in Vim. For example, I map Ctrl-Enter to send a ^[O2P escape code, which I then use to define a Ctrl-Enter key-mapping in my Vim: set <F13>=O2P map <F13> <C-CR> inoremap <C-CR> <C-O>o It works in a regular iTerm session, and in a...
I got this working by adjusting the escape codes to watch for in my .vimrc. I still wish I had a better understanding of how all this works, and why the sequence sent by tmux differs from what's sent outside of tmux, but this got everything working: if &term =~ "screen" set <F13>=[1;2P set <F14>=[1;2Q set <F1...
Can I get my iTerm key-combos working in tmux?
1,511,064,482,000
I have the following at the bottom of my ~/.bashrc which shows the last command run and the current working directory at the time of the last command in the title of my terminal window. trap 'echo -ne "\033]2;$(history 1 | cut -d" " -f3-) ••• $(pwd)\007"' DEBUG If I remove this, then URxvt functions as expected with ...
trap 'last_cmd=$(history 1 | cut -d" " -f3-); echo $last_cmd ••• $(pwd) | awk '\''!/\007/ {printf "\033]0;%s\007", $0}'\' DEBUG
URxvt not working properly with backslash characters \n and \t (given my particular ~/.bashrc configuration)
1,511,064,482,000
I am receiving a query via a configuration file in unix, for ex. Config file content will be in the format: Table_name|query ABC|select ABC.A,ABC.B from PQR left join (select * from ABC) on ABC.pk=PQR.pk I am trying to process query part as below : while read line in config_file do query=`echo $line...
Hi Saket Mankar and welcome to the community! You would need to enclose the $line variable with double quotes: "$line". That should solve your situation.
Processing parameters with * passed to unix [duplicate]
1,511,064,482,000
When running ls in terminal, output is variously colored: AFAIK this colorasing is accomplished by espace sequences (vt). But running ls | hexdump -cC shows only characters and LFs. Redirection to file leads to similar results. How is that?
GNU ls only outputs escape sequences for colorized text when writing to a terminal, not when redirected to a file or pipe. For that, use ls --color=always. The GNU ls manual says: Using color to distinguish file types is disabled both by default and with --color=never. With --color=auto, ls emits color codes on...
Why don't I see escape sequences in redirected stream OR how is color output implemented? [duplicate]
1,511,064,482,000
I don't understand this escaping. Is some generator available for it? i need replace normal text (185...) with Variable $NEW_DNS sed -i "185.228.168.168,185.228.169.168|$NEW_DNS /etc/wireguard/wg0.conf Output sed: -e expression #1, char 4: unknown command: `.' Update: i have like you can see answers and its work, j...
If you want to replace that string itself with what you have in the variable: sed "s|185\.228\.168\.168,185\.228\.169\.168|$NEW_DNS|" /etc/wireguard/wg0.conf You need sed s|string|replacement|. You can use sed s|string|replacement|g to replace it throughout the file. You also need to escape . with a backslash so it d...
Sed escaping "." and use $variable?
1,401,895,989,000
When I run ifconfig -a, I only get lo and enp0s10 interfaces, not the classical eth0 What does enp0s10 mean? Why is there no eth0?
That's a change in how now udevd assigns names to ethernet devices. Now your devices use the "Predictable Interface Names", which are based on (and quoting the sources): Names incorporating Firmware/BIOS provided index numbers for on-board devices (example: eno1) Names incorporating Firmware/BIOS provided PCI Expres...
Why is my ethernet interface called enp0s10 instead of eth0?
1,401,895,989,000
I have a Dell XPS 13 ultrabook which has a wifi nic, but no physical ethernet nic (wlan0, but no eth0). I need to create a virtual adapter for using Vagrant with NFS, but am finding that the typical ifup eth0:1... fails with ignoring unknown interface eth0:1=eth0:1. I also tried creating a virtual interface against ...
Setting up a dummy interface If you want to create network interfaces, but lack a physical NIC to back it, you can use the dummy link type. You can read more about them here: iproute2 Wikipedia page. Creating eth10 To make this interface you'd first need to make sure that you have the dummy kernel module loaded. You c...
How can I create a virtual ethernet interface on a machine without a physical adapter?
1,401,895,989,000
I am searching for an explanation what exactly the output of the commands ip link and ip addr means on a linux box. # ip link 3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:a1:ba:51:4c:11 brd ff:ff:ff:ff:ff:ff 4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,...
Those are interface's flags. They are documented in the netdevice(7) man-page. Below is the relevant part (reordered alphabetically): IFF_ALLMULTI Receive all multicast packets. IFF_AUTOMEDIA Auto media selection active. IFF_BROADCAST Valid broadcast address set. IFF_DEBUG Internal debugging flag....
ip link and ip addr output meaning
1,401,895,989,000
I am using Raspberry Pi using Raspbian which is just Debian. I would like to bridge from the primary WiFi network router that connects to Cox Cable to my cabled router here for my subnet to have reliable internet access. It needs to be a WiFi-to-Ethernet bridge. I have set /etc/networks for a static address for t...
For configuring a bridge from ethernet to wifi, it is as simple as doing in your /etc/network/interfaces: auto eth0 allow-hotplug eth0 iface eth0 inet manual auto wlan0 allow-hotplug wlan0 iface wlan0 inet manual auto br0 iface br0 inet static bridge_ports eth0 wlan0 address 192.168.1.100 netmask 255.255.255...
How do I configure a network interface bridge from WiFi to Ethernet with Debian?
1,401,895,989,000
I have two computer, both with linux, which are currently connected to a router/switch via a 1000Mb/s ethernet port (installed in mb). This allows me to transfer data at max 120MB/s between two hosts. As I need to increase this speed, would it be possible to install two 2.5Gb ethernet card in the two PCIe slots of bot...
Yes, it is possible. You, most likely, would need to install "link bonding driver". A driver which would balance and synchronize packets sent over two (or more) links. It is not a part of default setup in most distributions, but available in repositories. For Ubuntu family, for example, you can get a nice instruction...
Can I use two ethernet card to increase transfer speed between two linux OS in lan?
1,401,895,989,000
In the following example: $ ip a | grep scope.global inet 147.202.85.48/24 brd 147.202.85.255 scope global dynamic enp0s3 What does the 'brd' mean?
brd is short for broadcast. 147.202.85.255 is the broadcast address for whatever interface that line belongs to.
meaning of "brd" in output of IP commands
1,401,895,989,000
I am running KVM on RHEL6, and I have created several virtual machines in it. Issuing ifconfig command to the host system command line shows a list of virbr0, virbr1... and vnet0, vnet2... Are they the IP addresses of the the guest OS? What are the differences between virbr# and vnet#?
Those are network interfaces, not IP addresses. A network interface can have packets from any protocol exchanged on them, including IPv4 or IPv6, in which case they can be given one or more IP addresses. virbr are bridge interfaces. They are virtual in that there's no network interface card associated to them. Their r...
What is the difference between virbr# and vnet#?
1,401,895,989,000
I'm trying to set up a system that joins an untagged Ethernet network to a TAP tunnel, adding a VLAN tag as the traffic moves to the tunnel. So far I have: eth0 - the physical Ethernet interface carrying untagged traffic. tap1 - the TAP tunnel interface. br0 - a bridge that contains tap1 (and some other physical inte...
Yes: you can set the bridge to be VLAN aware. The bridge will then handle VLAN IDs attached to frames crossing it, including tagging and untagging them according to configuration, and will send a frame belonging to a given VLAN only to ports configured to accept it. This moves all the settings to the bridge itself rat...
Bridged interfaces and VLAN tags
1,401,895,989,000
On my wired LAN, with 1GBit/s devices, I have two Linux machines (One Haswell, One Skylake Xeon) and when I do a secure copy of a large file, I see 38MB/s. Seeing that this is 3 times below the 1000Mbit/s spec, I wonder if this performance is as expected? Both machines use SSD for storage, both run 64bit Ubuntu. Durin...
It does seem slow from a theoretical stand point although I've not seen any transfers much quicker practically on home hardware. Some experiments you might like to try to rule out possible limiting factors: Assess your raw SSH speed by copying from /dev/zero to /dev/null. This rules out a HD bottle neck. ssh remote_...
scp performance over 1Gbit LAN
1,401,895,989,000
I have a device that I need to connect to over SSH. The device is connected to my workstation via a direct ethernet connection. I'm attempting to assign the connected device an IP address somehow that I can SSH to, however all of the guides I'm finding have the user configure the IP from whatever device they're workin...
The link given by @steve as a comment is appropriate, but if you want to try something simple first just to see what the device does you can use dnsmasq, which is a simple dns and dhcp server. Install with sudo apt-get install dnsmasq. If this also enables and starts the server you need to stop and disable it. If, say...
How to connect to device via SSH over direct ethernet connection
1,401,895,989,000
I am running Arch Linux (on a Raspberry Pi 3) and tried to connect both the Ethernet and the Wi-Fi to the same network. route shows me the following: $ route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 1024 ...
As you have found out, from the routing perspective, while possible, it is not ideal to have addresses from the same network in different interfaces. Routing expects a different network per interface, and ultimately one of them will take precedence over the other in routing, since they overlap. The advised solution fo...
Possible to have both Wi-Fi and Ethernet connected to the same network?
1,401,895,989,000
As I was trying in vain to fix a faulty ethernet controller here, one thing I tried was running tcpdump on the machine. I found it interesting that tcpdump was able to detect that some of the ICMP packets the ping application thought it was sending were not actually going out on the wire, even though it was running on...
Yes. By putting network interfaces into promiscuous mode, tcpdump is able to see exactly what is going out (and in) the network interface. tcpdump operates at layer2 +. it can be used to look at Ethernet, FDDI, PPP & SLIP, Token Ring, and any other protocol supported by libpcap, which does all of tcpdump's heavy lif...
what level of the network stack does tcpdump get its info from?
1,401,895,989,000
In Linux, is there any difference between after-ip link down-condition and real link absence (e.g. the switch's port burned down, or someone tripped over a wire). By difference I mean some signs in the system that can be used to distinguish these two conditions. E.g. will routing table be identical in these two cases?...
There are difference between an interface which is administratively up but disconnected or administratively down. Disconnected The interface gets a carrier down status. Its proper handling might depend on the driver for the interface and the kernel version. Normally it's available with ip link show. For example with a...
The difference between ip link down and physical link absence
1,401,895,989,000
I have a debian linux box (Debian Squeeze) that deadlocks every few hours if I run a python script that sniffs an interface... The stack trace is attached to the bottom of this question. Essentially, I have a Broadcom ethernet interface (bnx2 driver) that seems to die when I start a sniffing session and then it tries...
Commenting out my code that called ethtool to modify the NIC buffers stopped watchdog timers from tripping on the bnx2 card. I still want to find an answer to the question about watchdog timers, but I will ask another question def _linux_buffer_alloc(iface=None, rx_ring_buffers=768, netdev_max_backlog=30000): ...
Solving Ethernet watchdog timer deadlocks
1,401,895,989,000
Given a Linux server with an ethernet card, another device say an unconfigured router is connected with a patch lead (or an ethernet lead cabled in a different way if needed). They're both powered up. Is there a way on the linux box to get the MAC address of the other device? There's no IP network going on here just ...
If I'm not mistaken, ARP could be used to receive a MAC address of a machine. If you are connected at the data-link layer, I believe you can execute arp -an on a Linux machine to retrieve the MAC addresses of connected devices. I've only used it to retrieve the MAC address associated with IP addresses, as that's what ...
Get MAC address of a directly connected device
1,401,895,989,000
I recently noticed I am only getting 100Mbit/s of througput on my gigabit home network. When looking into it with ethtool I found my ArchLinux Box was using 100baseT/Half as link speed instead of 1000baseT/Full which its NIC and the switch connected to it support.I am not sure why but the NIC seems to not be advertisi...
After hours of searching I found the solution in the most obvious place: NetworkManager seems to somehow have disabled autonegotiation right in the settings for my ethernet port: The weird part is that even after knowing NetworkManager can change the ethernet link-mode I cannot find even a single source online detail...
Linux disables ethernet auto-negotiation on plugging-in the cable?
1,401,895,989,000
I am trying to identify NICs on ~20 remote servers (2-6 NICs on every server). To begin with, I want to identify those ready for use and free ones. How can I check the state of the physical media? I know some ways, including ifconfig|grep RUNNING, ethtool, cat /sys/class/net/eth0/carrier, but all they require that the...
ip link show , by default shows all the interfaces, use ip link show up to show only the running interfaces. You could use filters to get the difference.
Check whether network cable is plugged in without bringing interface up
1,401,895,989,000
Today I removed my GPU out of an Linux (Ubuntu) machine, and after that the ethernet stopped working. Running 'service networking restart' threw an error message, and when I ran 'ifconfig' only the local loopback was visible. After this I re-installed my GPU and out of nowhere the internet started working again?? I wo...
Your networking devices are renamed to correspond with their location on the PCI bus. When you removed your GPU, your ethernet device changed from enp2s0 to enp1s0. In order to reconnect, you have a few options: Create profiles for enp1s0 that match those of enp2s0 Change the rules for naming devices to give this car...
Internet not working without gpu installed?
1,401,895,989,000
How can I disable my Wifi radio when I've connected to a network via Ethernet (wired), but enable the Wifi connection if I don't have a wired connection? Essentially, I want XOR switch for my wired/wireless connection states.
I found a script by Ilija Matoski to accomplish exactly this, which would belong in /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh. #!/bin/sh name_tag="wifi-wired-exclusive" syslog_tag="$name_tag" skip_filename="/etc/NetworkManager/.$name_tag" if [ -f "$skip_filename" ]; then exit 0 fi interface="$...
Disable Wifi on Connection to Ethernet with NetworkManager
1,401,895,989,000
With a bash script, can I read the mac address of my eth0 and print it to a file?
ifconfig will output information about your interfaces, including the MAC address: $ ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:55 inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.0.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:289748093 errors:...
Print mac address to file
1,401,895,989,000
I have set up a network as such: Set up host-only networking on VirtualBox. The first adapter is configured with NAT, the second with host-only networking HOST: Windows GUEST: CentOS VM1, CentOS VM2 (clone of VM1) When executing ifconfig -a on both VMs, I noticed that the MAC addresses are exactly the same. My quest...
This is one of those things that surprises people because it goes against what they've been taught. 2 machines with the same hardware mac address on the same broadcast domain can talk to each other just fine as long as they have different IP addresses (and the switching gear plays nice). Lets start with a test setup: ...
Identical MAC address on two different VM, yet I have internet connectivity
1,401,895,989,000
I have a problem with an ASUSPRO B8430UA laptop: when I boot it with Ubuntu 16.04 (or NixOS 16.03) the Ethernet port does not work. The driver used is e1000e, it reports: $ dmesg | grep e1000e [ 5.643760] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k [ 5.643761] e1000e: Copyright(c) 1999 - 2015 Intel Corpo...
I managed to fix the checksum. Now Ethernet works fine under Linux. I explained the details in my answer to my SuperUser.SE question. Basically, I first patched e1000e to skip the NVM checksum validation for (i = 0;; i++) { if (e1000_validate_nvm_checksum(&adapter->hw) >= 0) break; if (i == 2) { ...
Intel Ethernet Connection I219-V not working under Linux on an ASUSPRO B laptop, e1000e driver reports: "The NVM Checksum Is Not Valid"
1,401,895,989,000
I have CentOS 6.3 running in a (virtual) machine with two Ethernet adapters. I have eth0 connected to a TCP/IP LAN and eth1 connected to a DSL modem. The system is intended as a dedicated router/firewall, and has iptables set up to do SNAT, DNAT, and the desired filtering. This was working great but I changed DSL mo...
Just remove the IPv4 and IPv6 addresses with ip addr flush dev eth1 and ip -6 addr flush dev eth1.
How can I disable TCP/IP for an Ethernet adapter?
1,401,895,989,000
My problem is that I need to backup the files on my Linux machine to my Windows laptop. My external hard drive died, and so backing up to an external drive is out of the question for the time being. These are the methods I've tried: Samba Samba with Gadwin GUI Windows Shared Folder, Wirelessly (I can't access it, ev...
NitroShare may be able to do what you're looking for. It is a small app that allows files to quickly be sent between machines on the same network. Once installed on both your Linux and Windows machines, the two machines should automatically discover each other. Use the menu in the system tray to send a file or directo...
Transfer files between Windows and Linux machines?
1,401,895,989,000
I have two Linux boxes. One is running KNOPPIX and the other Ubuntu. I have only one wifi dongle between them, and only one of them has an Ethernet port. They both have free USB ports however. I need the box with the dongle to share the connection through a male-to-male USB cable. I know it is possible to do a s...
Without any deeper knowledge, I would suggest looking at the Linux USB Project, section USB Host-to-Host Cables, and possibly Easy Transfer Cable (although that seems to be mainly a Windows thingy). In any case you are likely to need additional hardware, because the cable probably is not "just wires".
How do I share an internet connection through USB?
1,401,895,989,000
Currently the Ethernet ports in the building I work in are down, but the Wi-Fi works. I have a Wi-Fi-enabled laptop (Ubuntu 14.04 LTS (Trusty Tahr)) and a non-Wi-Fi enabled workstaion (Debian 8 (Jessie)) with only an Ethernet plug. Is it possible to connect the two via an Ethernet cable and be able to get network conn...
Yes, you can do this, and it's not even that hard. I have a laptop with a wireless card, and an ethernet port. I plugged a RapberryPi running Arch Linux into it, via a "crossover" ethernet cable. That's one special thing you might need - not all ethernet cards can do a machine-to-machine direct connection. The other ...
"Pipe" Wi-Fi signal through Ethernet cable
1,401,895,989,000
I'm using elementary OS (based on Ubuntu 12.04) and yesterday I woke up to no wired ethernet connection. As far as I can remember I changed absolutely nothing, it was working at night and not anymore the next morning. If I plug in my USB wi-fi antennae it picks it up immediately so it's not my connection/modem. If I s...
I would start at the bottom of the stack and confirm that the Ethernet device is actually getting detected by the OS first. Example $ sudo lshw -c network -sanitize *-network description: Ethernet interface product: 82577LM Gigabit Network Connection vendor: Intel Corporation ...
No wired ethernet connection
1,401,895,989,000
I'm almost to the point where I can post the solution I wound up with for my complex port bonding question. However, in reading the bonding.txt file, I see this option text: ad_select Specifies the 802.3ad aggregation selection logic to use. The possible values and their effects are: stable or 0 The active a...
Yes, given the following config: .-----------. .-----------. | Switch1 | | Switch2 | '-=-------=-' '-=-------=-' | | | | | | | | .-=----.--=---.---=--.----=-. | eth0 | eth1 | eth2 | eth3 | |---------------------------| | bond0 | '-------------------...
Bonds vs. Aggregators
1,401,895,989,000
i am using centos 7. I am typing the command ip addr show eth0 but its reply Device "eth0" does not exist.
In CentOS, network interfaces are named differently. So they aren't called eth0 or eth1, but rather have names like eno1 or enp2s0. (Source.) Run ip addr to see how these interfaces are named on your system. These names are defined in /etc/sysconfig/network-scripts/ifcfg-<iface>. You can change their names if you real...
Device "eth0" does not exist
1,384,222,990,000
I know that I can find which network interface is currently being used by parsing the output of: # ifconfig or # route But how can I get this information as a non-root user? Is there a way I can build such a $ magic-command whose ouput would be none lo or wlan0 or eth0 depending on the device used.. or even enp3s0f...
Something like this? ip addr | awk '/state UP/ {print $2}' enp0s3: This command was issued as a "regular" (non-root) user on: uname -a Linux centos 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux If it is important to remove the trailing : from the interface name, use (for ex...
How can I find active network interface from userland?
1,384,222,990,000
I want to connect a PC to the internet via my notebook, which is connected to a WLAN. The setup should look like the following scheme: PC (eth0) -> Notebook (eth0) -> Notebook(wlan0) -> Router. Both are running linux - arch on the notebook and funtoo on the PC. Edit: So I tried rush's method and it didn't work for me,...
It's pretty easy. You need to connect PC to notebook. Configure eth0 on PC (set for example ip = 192.168.2.3 and default gateway 192.168.2.2 and dns server to 8.8.8.8). That's all you need to do on PC. On notebook you need to set up the internet connection as usual and configure eth0 with the following way: set ip add...
Using the Wifi of a notebook via ethernet for another PC
1,384,222,990,000
We have a RHEL 5.5 box with 8 interfaces. And the eth interface naming is flip flopping. Sometimes eth0 comes up on physical port 7th, and sometimes on another physical port. We want the naming to be as per the sequence of PCI BUS. I did the research and found that cat /sys/devices/pci0000\:00/0000\:00\:1e.0/0000\:0...
Have you tried including the MAC addresses in the different ifcfg-ethX files for the various ethernet devices? Additionally you can control which device get's which ethX handle through udev's 60-net.rules file. For example # /etc/sysconfig/network-scripts/ifcfg-eth0 # Intel Corporation 82573E Gigabit Ethernet Control...
RHEL: Creating stable names for network interfaces
1,384,222,990,000
I am looking to do this on a Raspberry Pi, but I don't mind which operating system I have to install, so the easiest most out-of-the-box solution for Pidora (Fedora 20 Remix), Raspbian (Debian) or Arch is the one I'd like. I am living in a university building where internet access is supplied via a protected wireless ...
This is as simple as it could be. You do not need any bridging. Just MASQUERADE your local network on RPi: iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE Enable forwarding of traffic: echo 1 > /proc/sys/net/ipv4/ip_forward RPi will not work as invisible bump-on-the-wire but will need a network setup between it ...
How can I most simply transparently bridge traffic between wlan0 and eth0?
1,384,222,990,000
I did an upgrade from Xubuntu 12.04 to 12.10, and I can't connect to the internet now. When I press the network button on the panel, I see "No network devices available" on top (greyed out), then "VPN Connections", "Enable Networking" with a checkmark next to it, "Information" (greyed out) and "Edit". Here's the outp...
This question turned out to have two answers, both suggested by @JosephR in the comments. 1) Fixing the /lib/modules/3.5.0-030500-generic/build: No such file or directory error while trying to install the ethernet driver just needed a sudo ln -sv /usr/src/linux-headers-$(uname -r) /lib/modules/$(uname -r)/build - afte...
No ethernet/wireless connection after dist upgrade - "network UNCLAIMED"
1,384,222,990,000
I've installed docker on Ubuntu 16. Now I can no more connect to my wired network : ubuntu is using docker0 ethernet interface to connect to the network (the wifi interface still works) To resolve the problem I have to shutdown docker daemon and then shutdown docker0 interface : $ sudo link set docker0 down But if I ...
Looks like the docker network is interfaring with your host network. You need to customise the docker network , and set it to a different network than your host network before starting docker. https://docs.docker.com/v17.09/engine/userguide/networking/default_network/custom-docker0/
docker0 network interface is screwing up my network
1,384,222,990,000
The issue: I recently bought some new hardware and am running into issues getting Ethernet to work, as no combination of kernels and drivers I've tried is working. I've hypothesized the issue is either faulty hardware, or poor device support (due to how recently its been released). But given what I've tried below, I'm...
Turns out, it was most likely a hardware issue. I got a replacement motherboard, and the networking hardware was, curiously enough, recognized by the Debian 10.7 installer (it seems my understanding of which versions of e1000e were included with Debian's kernels was wrong... I should look into that.) Hopefully other p...
e1000e error with B460 Motherboard and Intel I219-V Chipset
1,384,222,990,000
I have enabled the arp support on my dell based server running linux on it. I wanted to check that if arptables are enabled or not. Could anyone tell me how do I check the same? Is it enough to run arp command here?
The TCP/IP protocol will not work without ARP so that is always available. Normally ARP works automatically and doesn't require manual intervention. As the other posts mention cat /proc/net/arp displays the current arp table/cache without using specific tools. You can manipulate the arp cache and static entries with ...
How to check if ARP is enabled or not
1,384,222,990,000
In Arch Linux, how can I check if a network device (say eth0) has a carrier signal present?
cat /sys/class/net/eth0/carrier is by far the easiest method.
How can I test the current carrier state for an ethernet adapter in Linux?
1,384,222,990,000
I am looking for a kernel parameter that I could use in the GRUB config to disable EEE (Energy Efficient Ethernet, wikipedia) permanently on my LAN (wired Ethernet) card of my newish laptop: Basic info: OS: Linux Mint 21.1 "Vera" Cinnamon # ethtool -i enp59s0 driver: r8169 version: 5.15.0-56-generic firmware-version:...
No such kernel parameter exists. However, there are other ways to achieve your goal than an @reboot cron job. If you're using NetworkManager, you could create a pre-up dispatcher script (e.g. /etc/NetworkManager/dispatcher.d/pre-up.d/disable-eee) to make the configuration change as the network interface is activated: ...
How to permanently disable EEE (Energy Efficient Ethernet) on Ethernet card?
1,384,222,990,000
I'm in a situation where I have a 10/100/1000-capable PHY cabled only to support 10/100. The default behaviour is to use the autonegociation to find the best mode. At the other end, using a gigabit capable router ends in a non-working interface. I guess autonegociation never converges. I've heard some people tried wit...
The thing with autonegotiation is that if you turn it off from one end, the other side can detect the speed but not the duplex mode, which defaults to half. Then you get a duplex mismatch, which is almost the same as the link not working. So if you disable autonegotiation on one end, you practically have to disable it...
Remove SOME advertised link modes with ethtool
1,384,222,990,000
Is there any (reliable) way to find out if the PC booted because of a Wake-on-LAN Packet instead of pressing the power button? I want automatically check if WOL is correctly configured. I know about ethtool's WOL output, but this just tells me if WOL is turned on, not how the PC booted, right?
Manually testing using etherwake I think you can test it using a tool like etherwake. Depending on the distro it's called etherwake on Ubuntu/Debian, ether-wake on RHEL/CentOS/Fedora. I had it installed already by default on Fedora, it's part of the net-tools package. To use it: # Redhat $ ether-wake 00:11:22:33:44:55...
Find out if computer started via Wake-on-LAN or power button?
1,384,222,990,000
It is well-known that systemd changes the network interface names from e.g. eth0 to enp0s25, and this is called "Predictable Network Interface Names". On my system, eth0 is called "enp0s31f6". And I'm sorry to say this, but I too agree with this user that says "I see little irony in word "predictable"" https://askubun...
Why did it stop working? What did I do wrong? It's hard to tell what happened "suddenly". Review your /var/log/syslog or /var/log/messages for DHCP logs around the time it stopped working and you may find out. Also check the modification time in stat /etc/network/interfaces. Why was it ever eth0 in my /etc/network/...
How is systemd supposed to work regarding network interfaces?