date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,361,651,451,000
I'm running OpenSuse with dwm as a window manager. Since I made the switch from KDE, I haven't found a way to take a screenshot or even capture part of my screen. Is there a way I can do this in a command-line environment?
The euphoniously named scrot takes screenshots from the command line... It has a couple of simple options, including a time delay and image quality. If you are wanting to take a shot in the console, and you are running a framebuffer, then you can use fbgrab.
Capturing area of the screen without a Desktop Environment?
1,361,651,451,000
I would like to display Chinese characters in dwm's status bar. More specifically I would like the symbols to represent the different tags in dwm. Using an online converter, I found that the unicode representation for the symbols I want is: 憤怒 unicode: 憤怒 Putting the unicode characters directly into my ...
I don't think you'll get Unicode support from dwm without patching it (and adding additional dependencies, notably pango). If that's an option for you, the pango patch from the official list of patches seems to work, just run patch command in the dwm folder passing the patch file to the standard input: $ tar xzf dwm-6...
Unicode characters in uxterm and dwm statusbar
1,361,651,451,000
I'm running dwm with dmenu under Arch Linux. While dmenu is working, it doesn't start some programs, e.g., emacs, although it shows the command with auto-completion. When I start them in the terminal, it works fine. What can I do? Is there an error log file for dmenu?
dmenu doesn't have built in logging, but it is a very simple program and it is not difficult to have it log it's output to a file. First, determine where pacman has placed the dmenu files with pacman -Ql dmenu. You should get: dmenu /usr/ dmenu /usr/bin/ dmenu /usr/bin/dmenu dmenu /usr/bin/dmenu_path dmenu /usr/bin/dm...
Dmenu does not start some programms (e.g., emacs) -- is there a log file?
1,361,651,451,000
In KDE, there was a system setting where you could specifically set the monitors to never go black. Now I've switched to dwm and (it might not be related) my screens dim after about 10 minutes. How do I change this setting directly from the command line? I'm guessing this has to do with X?
You need to change the DPMS settings, which are controllable with xset. You can disable all DPMS with: $ xset -dpms And re-enable them with: $ xset +dpms You can also control how long before the monitor switches into each state (standby, suspend, and off; they're explained in this Wikipedia article) by passing 3 int...
How to prevent my screens from dimming (going black) from the command line
1,361,651,451,000
I'm using the dynamic window manager of suckless (dwm). I noticed that firefox is able to send nice notifications when a download has finished. See the two figures When I'm on a different tag, I get this kind of notification (inverted 1 tag) upon a finished download. I'd like to use this kind of notification for my...
This is probably the urgency hint which can be set on windows. This hint is recognized by most window managers. Most terminals can be configured to set the urgency hint when receiving a bell. (u)xterm for example has the bellIsUrgent option and (u)rxvt has urgentOnBell. To ring the bell in a terminal just run tput bel...
What kind of notification is Firefox sending when a download has finished?
1,361,651,451,000
I'm trying to create an array of simple hotkeys on my desktop, running OpenSuse with dwm. Things like: Ctrl+E /opt/eclipse/eclipse Can this be configured from within dwm? If not is there an external application which I can run (in the background) to listen for these hotkeys. Also, is it possible for the hotkeys to...
You can configure hotkeys in your config.h. To use your eclipse example (with a rule to have it open in a specific tag1 when you hit Ctrle: static const Rule rules[] = { { "Eclipse", NULL, NULL, 1 << 0, False, -1 }, ... /* commands */ static const char *eclipsecmd[] = { "/opt/eclipse/ecl...
Custom hotkeys in dwm
1,361,651,451,000
I'm writing a bash script to print system stats to my dwm status bar using xsetroot. Everything works as expected. What I'm currently missing is an easy way that just uses standard *nix tools to give me the current load for every core on my system (I have 4 cores.). I can't figure out how to do this e.g. using top. Al...
Calculating the average per core usage from /proc/stat The best solution I have come up so far uses bc to account for floating point arithmetic: # Calculate average cpu usage per core. # user nice system idle iowait irq softirq steal guest guest_nice # cpu0 30404 2382 6277 554768 6061 0 19 0 ...
How to get cpu usage for every core with a bash script using standard *nix tools
1,361,651,451,000
I would like to use the inconsolata font in dwm's statusbar. Right now my config.h is set up like so using terminus: static const char font[] = "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"; I tried changing that to: static const char font[] = "-*-inconsolata-medium-r-normal-*-17-*-*-*-*-*-*-*"; But it didn't wor...
There is a (reasonably old) thread on the suckless mailing list about this issue, that includes a patch: called pango. There is slightly more recent version in the AUR for 5.8.2: https://aur.archlinux.org/packages.php?ID=33193
How do I add Xft suppport to dwm?
1,361,651,451,000
I'm using Pertag patch As a Gentoo user I apply dwm patches using Portage. Basically there's a directory where user can put a patch for sourcecode and Portage will apply it during the compilation process (if patching procedure goes wrong whole compilation will fail) So basically I used just these commands: cp ~/pertag...
dwm is an acronym for dynamic window manager: the central principle of dwm is that the tags are supposed to be dynamic, not fixed. See why tags don't remember their layout. The pertag patch breaks this paradigm. If you want to be able to have your window manager use static workspaces, you are better off using xmonad o...
Dwm - pertag patch - save state between restarts
1,361,651,451,000
I'm currently running Fedora 19 on my PC and I want to remove GNOME and then use dwm. Is it enough when I install dwm and remove GNOME completely?
You don't have to remove GNOME to use dwm, you can just install dwm and use it instead. Removing GNOME might simplify cirvumventing xdm/gdm (dm = display manager; these are the things that control the graphical login) -- but it also might not. If you install multiple DEs, they may configure the dm to use a chooser, h...
Remove GNOME and install dwm
1,361,651,451,000
I've been using KDE on Opensuse for some time now and I feel like improving performance and using the most of my dual screens. I discovered tiling window managers and thought it would be a cool thing to try out. However, I'm stuck on a couple of issues. Will all my applications still be compatible? LibreOffice? Googl...
I have lots of experience using xmonad and I think you'll be fine if you give it a whirl. Regarding your specific questions: Almost everything will work just as they normally do. Regarding the specific list you gave, the only one that needs some TLC is chrome. Full screen is a bit flaky and you'll need to futz wit...
Easily switching over to a dynamic window manager from KDE
1,361,651,451,000
I'm trying to add the transparency patch to dwm. I downloaded the .diff file and in my dwm directory ran this: max@linux-vwzy:~/misc/dwm/dwm-5.9> patch < dwm-transparency.diff patching file config.def.h patching file dwm.c Hunk #1 FAILED at 58. Hunk #5 succeeded at 306 (offset 1 line). Hunk #6 succeeded at 847 (offse...
The patch is failing because the other patches that you have previously applied have shifted the code around sufficiently to defeat patch's attempts to apply the change, even with an offset (as can be seen in those hunks that did succeed). If you open dwm.c.rej you will see the failed hunks, then it is just a matter o...
Patching a file (in this case dwm) and failed hunks
1,361,651,451,000
I'm using dwm with the dualstatus patch. This adds a status bar on the bottom of the screen, in addition to the standard bar at the top. The text in each bar is set in ~/.xinitrc (for example) like this: xsetroot -name “top text;bottom text” Is there a way in bash to set the top text and bottom text at different inte...
I would suggest having bash keep track of your previous bottom string and only update it once a minute (when seconds of the current time modulo 60 is equal to 0 in this code). while true; do (( 10#$(date +%s) % 60 )) || bottomdisp=$(date) xsetroot -name "$(topbar);$bottomdisp"; sleep 1; done & This synt...
Is it possible to use xsetroot and dwm to set the top and bottom bars at different time intervals?
1,361,651,451,000
I am trying to build dwm from source. Grabbing the source doesn't work: (28) $ apt-get source dwm Reading package lists... Done Building dependency tree Reading state information... Done E: You must put some 'source' URIs in your sources.list This is my sources.list file: ## CRUNCHBANG ## Compatible with Debia...
Don't forget to run apt-get update after changing your sources.list.
Error while trying to retrieve dwm sources
1,361,651,451,000
I have a laptop with an external monitor and I want to use the external monitor as the primary one. I'm also running Debian with dwm. xrandr -q gives me this: Screen 0: minimum 320 x 200, current 3286 x 1080, maximum 8192 x 8192 LVDS1 connected 1366x768+1920+0 (normal left inverted right x axis y axis) 345mm x 194mm ...
The default dwm behaviour is to open applications, with a rule or not, on the monitor/screen that has focus. To open Surf on the third tag of the currently focussed monitor, the rule would be: { "Surf", NULL, NULL, 1 << 2, True, -1 }, To open VLC on the second tag of the primary monit...
How do I configure multiple monitors to work with dwm's tag rules?
1,361,651,451,000
I recently installed dwm (a linux window manager) which extensivley uses Alt+Shift key combinations for navigation but none of them are working. For example Alt+Shift+c will close a window. I installed screenkey to check if my keyboard was working and saw that when I pressed Alt+Shift it registered as Alt+ISO_Next_Gro...
My issue was actually particular to MX-Linux. By default the "Layout Switch" key is set to Alt+Shift. You can change this in fskbsettings which is installed by default.
Alt+Shift Not Working, Getting Alt+ISO_Next_Group Instead
1,361,651,451,000
I have a dual screen setup which I've configured by running this command at startup: xrandr --output VGA-0 --auto --right-of DVI-0 I'm running OpenSuse 11.4 with dwm as my window manager. I can post the output of any command or dump any file if you think it will help. The problem happens when I try and run a fullscre...
I ended up being able to fix the issue by installing fglrx from the SuSE repositories. It seemed some capabilities (acceleration) were not supported in the open source version of the driver.
Can't run certain fullscreen applications
1,361,651,451,000
I am new to Arch and did a fresh install. I have configured it to use dwm and I start it with startx. The problem is that some commands in xinitrc seem to not run. It clearly works to some extend, because dwm is starting, but i can't say the same for other commands. My xintirc is located: ~/.xinitrc (or /home/xor/.xin...
The problem with your .xinitrc is that it just starts with exec. This particular way to launch some command (here dwm) makes dwm replace the running shell, hence forbidding everything further down to be launched. Quoted from man exec If exec is specified with command, it shall replace the shell with command without c...
xinitrc seems to not run some commands
1,361,651,451,000
I installed netbeans using zypper install netbeans. Trying to run it, I get the "loading" splash screen which is proceeded by a small popup which asks me if I want to register my copy and receive some benefits. Once that popup is gone, I'm left with a big beige screen and nothing else. It's almost like netbeans can't ...
There's the same type of problem for awesomewm and probably quite a few other window managers. The dmw wiki has a section on this: Fixing misbehaving Java applications. The solution proposed is to change the window manager name by installing wmname, and then running: $ wmname LG3D If that works, make sure that is cal...
Netbeans has no display on my computer
1,361,651,451,000
I am really struggling to get the session polkit to work. I am not really familiar with how it works, but I have been using gnome before switching to dwm and in gnome it worked perfectly, so I wanted to replicate that. First of all: As I understood it, the polkit is responsible for giving momentary privilege escalatio...
I use dwm as well, I have in a .xinitrc file, with a polkit to start at login. I use the xfce-polkit. /usr/lib/xfce-polkit/xfce-polkit & As an example I also use Thunar as my file manager and have a custom action that calls a root session of Thunar using pkexec. Using the polkit will give you the same DE behaviour w...
dwm - session polkit
1,361,651,451,000
I'm new to dwm (suckless.org) and also to GNU/Linux. I know a bit of the C language but don't really understand the config.h file. SYS-CONFIG I use Ubuntu 18.04 (installed with netinstaller + vanilla gnome...) and recently I wanted to try dwm 6.2. HOW I INSTALLED IT I downloaded the tar.gz file from the suckless.org w...
Here is the problem: static const char *termcmd[] = { "st", NULL }; The dwm build from suckless.org uses st as default terminal emulator therefore Alt+Shift+Enter is mapped to st which is not installed on your system. You need to change st to gnome-terminal or whatever other terminal emulator you want (and which i...
The default keybinding for opening a terminal in dwm does not work
1,361,651,451,000
The context I use dwm as my main windows manager and anki to create flashcards. The problem Some windows of the anki program are not correctly being displayed (see image or gif below) Gif Screenshot The question How can I make anki windows to be correctly displayed when using dwm? Additional context At a first glan...
I was helped in the Anki forum after creating a post. I solved the issue by executing $ ANKI_NOHIGHDPI=1 anki You can find further information on this issue in the related links that were posted by addons_zz in his reply to my post in the Anki forum.
Windows of the anki program are not correctly being displayed
1,361,651,451,000
I wrote a script for my dwm statusbar. One part of it is finding the current cpu usage for every single core on my system. I figured out a way myself but I would need some help fixing a bug in this. Here is the command: top -bn 2 -d 0.5 | grep -F '%Cpu' | tail -n 4 | awk '{print $3}'. This assumes that your top shows ...
The "stuff" between the values seems a visual representation of the newline character to me ( octal character code 12), which you would get when using: echo -e 'a\012b' What you could try is pipe the output through tr '\n' ' ' as with: echo -e 'a\012b' | tr '\n' ' '
How to print a bash variable that has an array as value
1,361,651,451,000
The context This gif shows what happens when trying to opening scilab while using i3 This gif shows what happens when trying to opening scilab while using dwm The problem I'm currently using dwm because using tags is more suitable in more workflow than using workspaces with i3, so in order to use scilab I have to sw...
This is a common rendering issue with Java applications and non-reparenting window managers. There are 2 solutions: Use wmname to impersonate another window manager, e.g. $ wmname LG3D Set no-reparenting flag for JDK export _JAVA_AWT_WM_NONREPARENTING=1
Scilab displays an empty screen when executing it while using "dwm" but not while using "i3"
1,620,517,149,000
What is it, the dependencies for comiple dwm from scratch for install dwm (suckless windows manager) in arch linux , i need to install xorg and make and other
Dependencies needed for compile dwm in void linux from scratch is: sudo xbps-install base-devel libX11-devel libXft-devel libXinerama-devel freetype-devel fontconfig-devel Dependencies needed for compile dwm in arch linux from scratch is: sudo pacman -S base-devel libx11 libxft libxinerama freetype2 fontconfig
How to install dwm in void linux
1,620,517,149,000
Edit: The border on the bottom is not set my me. i don't have it in my config.h file. To be honest wouldn't know how to set it. so, it doesn't happen with any other programs, just terminal emulators. in all of xterm, urxvt, st, and xfce4-terminal. Edit: I want to get rid of this empty space. is there a patch or some...
Most application windows (firefox, pcmanfm, libre office, etc) allow you to resize them in pixels. Most (all?) terminal emulators only allow you to resize them in characters - e.g. 80x24. On my XFCE system (with a 2560x1440 screen), I have a top panel (menus, short-cut icons, some status displays) and a bottom panel (...
border on the bottom of terminal emulators even in monocle view [closed]
1,620,517,149,000
I'm setting up key bindings in dwm for things like changing brightness and taking screenshots. In order to bind the appropriate key, I followed someone else's example and added #define XF86AudioMute 0x1008ff12 to my config.h, and referred to that key in my keybinding. This works fine, but I have no idea where this v...
The definition #define XF86AudioMute 0x1008ff12 comes from the header file XF86keysym.h, though it's spelled differently: #define XF86XK_AudioMute 0x1008FF12 /* Mute sound from the system */ To find the keysyms that your keyboard sends, use xev. Not all keys will send keysyms, however (in that case, you ca...
How do you find what value a keyboard key has? (dwm keybinding)
1,620,517,149,000
I recently started using dwm, which is really nice, but I have a problem with regards to my multi monitor setup. I have my monitors placed like the following: ----------------------------------------------------------------- | || | | ...
What I do is start dwm manually (e.g. using startx) and, before executing it in .xinitrc I have a xrandr command that sets up external monitors. xrandr supports position-related arguments of the form "display x is above display y" and so on.
screen placements on dwm
1,620,517,149,000
I find no way to switch between last two focused windows. How can I do that? There is Mod+Tab but for tags only.
Toggling between windows in a tag is done through changing the focus between next and previous: Mod1-j Focus next window. Mod1-k Focus previous window.
dwm. How to switch between last two windows?
1,620,517,149,000
I want to set up icons for my tags in dwm. I have downloaded the ttf-font-awesome package with sudo pacman -S ttf-font-awesome and I changed this line in my config.h of dwm: static const char *fonts[] = { "FontAwesome:size=16", "consolas:size=16" }; But it still doesn't work. Some icons show up correctly, while other...
The solution was quite simple. I had a Nerd font loaded also, and this font caused the icons to be loaded differently from what I expected. I removed the ner font and everything worked just fine.
dwm doesn't load fontawesome
1,620,517,149,000
I am running Arch Linux on a Dell XPS-13 9380 with the DWM window manager (which uses X11). I recently started using an external monitor with my laptop. My issue is that when and only when the second display is active, my terminal emulator glitches when I type into it. Please note that this only affects the terminal e...
It was an X11 problem. After installing the xf86-video-intel drivers (for the Intel UHD Graphics 620 chip. Consult the arch wiki to be sure). I added this to /etc/X11/xorg.conf.d: 20-intel.conf: Section "Device" Identifier "Intel Graphics" Driver "intel" Option "TripleBuffer" "true" Option "TearFree" "...
Terminal emulators glitch when using two displays (DWM)
1,620,517,149,000
I'm using archlinux, dwm and dwmblocks. At startup dwmblocks shows only the icons of the blocks', without loading the scripts output. If I run $ killall dwmblocks and restart $ dwmblocks & it loads all required modules flawlessly. For me, as a nonprofessional, it seems that the $PATH is not read before startx. So in...
The command source is not portable. That is a bash-specific (possibly also some other shells) alias to the standard POSIX shell command .. So, it looks like your .profile is being read by something other than bash which means you should use . and not source. Also, you can't be sure that $HOME will be set (it may well ...
dwmblocks not reading $PATH
1,620,517,149,000
I got as my first desktop environment gnome. As i go to DWM and wanna call the terminal by Alt+Shift+Enter, the terminal opens in gnome environment, but not in dwm.
in the source code of dwm there's a variable called "termcmd" assuming the terminal under gnome is called "gnome-terminal" you'll have to replace "st" with "gnome-terminal"
Terminal problem DWM
1,620,517,149,000
Is it possible to swallow a terminal running Tmux? I can't seem to get the patch working unless Tmux is disabled. I've tried with "Screen" on st and there were no issues :/. Thanks! https://dwm.suckless.org/patches/swallow/ (Using dwm-swallow-20200522-7accbcf.diff) EDIT: Couldn't figure it out, but found something awe...
I was having the same issue as you so I did some digging into how the swallow patch works and why it can't swallow tmux windows. Basically, dwm’s swallow patch is incapable of handling applications launched from terminal emulators running tmux because the patch figures out which window should be swallowed by finding t...
Suckless' DWM Swallow Patch + Tmux
1,620,517,149,000
I'm in the process of creating a nice looking statusbar with DWM and I want to implement unicode symbols with font awesome. Supposedly I can use the Pango patch but its out of date (for version 6.1) so patching fails. Is there another method I could use?
There was an XFT patch for 6.1 posted to the mailing list some time ago: that should work. Your only other option is to update pango for 6.1, which may be a significant task given the changes to dwm over that version bump.
DWM Unicode Support
1,620,517,149,000
I tried to introduce colors to the status bar with xsetroot, but that did not work (of course). I then found the status2d patch, but it did not use ansi color escape codes and it slows my statusbar down. Is there an alternative?
have you tried this patch? colored status text https://dwm.suckless.org/patches/statuscolors/
How do I bring color to my dwm status bar?
1,620,517,149,000
I want to add additional language input to my linux. I am using MX Linux and DWM desktop environment. How can I do this?
Since MX Linux is Debian based, you can set your keyboard layout using, sudo dpkg-reconfigure keyboard-configuration. The keyboard settings file is /etc/default/keyboard if you prefer to do it manually. You can set the layout, the available languages, variants and the key combination to switch layout/language. In Debi...
How to add keyboard layout in dwm
1,620,517,149,000
Since the last system update, for various applications the font size has increased. Even one application for which I can be sure, that it has not been replaced, because I have a custom version and install it from source (see dmenu). As you can see in the picture, the font for dmenu appears ridiculously large. The scr...
First I installed the xorg-xrdb package which provides X11 access to the file .Xresources . sudo pacman -S xorg-xrdb Then I created .Xresources inside my home directory with the following content *.dpi: 96 Lastly I have to make sure that .Xresources is loaded, so I added the following line to my .xinitrc xrdb -merge...
Why do some fonts appear zoomed in after system update?
1,620,517,149,000
I just got a quick question regarding dwm, how can I switch the places of two windows, so window A is switched with window B or is it even possible to move windows around? Because I just like to have my main windows open up on the left side of the screen, so I can easily look at them. The problem is that they sometime...
Figured it out myself, by default mod + Return switches the master and stack.
DWM: Switch two windows places | Move windows
1,620,517,149,000
I want to run Telegram Desktop as a background process on dwm, such that I receive notifications when I have a new message and such that I don't have to keep the GUI open the entire time. How would I go about that? Whenever I close the GUI, the process closes entirely and I don't receive notifications.
You can try patching it: https://dwm.suckless.org/patches/systray By default DWM doesn't sport a systray where Telegram could be minimized to.
How do I run Telegram Desktop as a background process in dwm?
1,620,517,149,000
I am attempting to set up the behavior described in the title. For reference, there is an answer which solve this for emacs. I however use DWM/ST and Zsh. The solutions I have clumsily tried to come um with include modifying the .zshrc file in the with the following lined: cd $pwd I have realized this does not make ...
I hope this does the trick: st & disown EDIT: You can make an alias to it and put it to your rc file (I don't know if it works on zsh) alias st='st & disown' So when you call it on the current shell it will open a new terminal on your current directory. Though alias are not inherited by subshells (you can define a ...
Opening Terminal in Current Directory [closed]
1,620,517,149,000
I'm using Arch Linux with dwm desktop. I was trying to make some changes in my ~/.xinitrc, and now my dwm status bar displays weird characters. I reverted all the changes i made in /etc/X11/xconfig.d and ~/.xinitrc, but the problem persists. The characters get also displayed on some web forms too (which makes it very ...
This is symptomatic of you not having installed a monospace font, and not having changed the font declaration in .config.h, the default which ships with dwm being: static const char *fonts[] = { "monospace:size=10" };
Dwm status bar and web forms display weird fonts
1,620,517,149,000
After seting up shortcuts in config.h, pactl is not working at all. However when I run pactl in terminal, it works as intended config.h: #include <X11/XF86keysym.h> static const char *upvol[] = { "/usr/bin/pactl", "set-sink-volume", "@DEFAULT_SINK@", "+5%", NULL }; static const char *downvol[] = { "/usr/bin/pac...
Turns out DWM in some cases must be fully reinstalled to overwrite some settings sudo make uninstall && sudo make install
pactl not working in DWM config file
1,330,333,166,000
I have destroyed my Mint Linux installation. I just wanted access to my remote storefront. So what happened was I was having trouble with ICEauthority file in my home directory. So following different directions on the internet I came to the conclusion that I could set the home directory recursively to chmod 755 to...
I found that running sudo bash and then running ecryptfs-recover-private as root (rather than via sudo) worked. Not sure why it should be any different. Edit: TL;DR: # ecryptfs-unwrap-passphrase /mnt/crypt/.ecryptfs/user/.ecryptfs/wrapped-passphrase - | ecryptfs-add-passphrase --fnek - < Type your login password ...
mount: No such file or directory with encrypted recovery
1,330,333,166,000
Someone ask me in other site about this question, i.e. a file named "abc.dat" has 0 file size but 8 blocks, and this is the output I ask him to give me (Some text has been translated from Chinese to English): $ cp abc.dat abc2.dat; ls -ls abc2.dat #try to copy, it still 8 blocks but 0 byte 8 -rw-rw-r-- 1 rokeabbey ro...
This happens if the file system is encrypted; the FS needs to store extra metadata for the file, even if it is empty. As I happen to have a machine handy with a vanilla ecryptfs mount (Ubuntu 12.04-LTS), I can confirm that an empty file will get 8 blocks: $ touch test $ ls -ls test 8 -rw-rw-r-- 1 admin admin 0 feb 27...
How is it possible 8 blocks get allocated but file size 0?
1,330,333,166,000
I can't do ssh public key login to my server and I think this issue is related to the fact my home is encrypted. I chose the option "encrypt my home folder" under the Ubuntu install setup. The permissions on /home/MY-USER are 700. I've tried another workstation and everything works fine. I would be glad if someone hel...
In the ssh_config file, you can can change the location of where it looks for your private key. You could probably do something like make a new folder at /etc/ssh/keys/ and put your id_rsa private key file in there and then change the IdentityFile option in ssh_config to look in the new location. In doing so you'll wa...
Can't do SSH public key login under encrypted home
1,330,333,166,000
Ecryptfs encrypts filenames and sometimes I need to find particular file, so I would like a tool to map the encrypted filenames back to their plaintext file name.
You would want to use the utility ecryptfs-find
Is there a tool to map ecryptfs plaintext and encrypted filenames?
1,330,333,166,000
On my Debian-Testing-System, I want to completely conceal the home folders. That means, I not only want the data to be encrypted, but I also want to preclude determining any (or most) information from the encrypted data. For instance, also file names should be encrypted. But not being an expert for data protection, ma...
Ecryptfs stores each encrypted file in one file (the lower file, in ecryptfs terminology). The directory structure of the lower files mirrors that of the payload files, although the file names are encrypted. The metadata (modification times, in particular) of the lower files also reveals that of the payload files. The...
conceal home folder completely - is ecryptfs the right choice?
1,330,333,166,000
I have an encrypted share folder on my synology NAS DS413 (which uses ecryptfs). I can manually mount the encrypted folder and read the decrypted files without issue, using synologies GUI. For some reason, I have never been able to mount the encrypted folder using my passphrase . But I can always do it by using the ...
Short answer: Use the passphrase $1$5YN01o9y to reveal your actual passphrase from the keyfile with ecryptfs-unwrap-passphrase (the backslashes escape the $ letters): printf "%s" "\$1\$5YN01o9y" | ecryptfs-unwrap-passphrase keyfile.key - Then use your passphrase with one of the instructions you probably already know,...
how to decrypt ecryptfs file with private key instead of passphrase
1,330,333,166,000
I installed Ubuntu LTS 14.04 server edition on a remote computer, and added my local public key to ~/.ssh/authorized_keys on the remote computer. I found that I still needed to use password to log in the remote computer, even after setting the permission of ~/.ssh to 700, and ~/.ssh/* to 600 on the remote computer. Ho...
Here is the solution from the link I posted in my comment. This comes from here, which references this superuser post. Create .ssh folder in /home for the keys to be stored sudo mkdir /home/.ssh Move existing authorized_keys file into .ssh dir as username sudo mv ~/.ssh/authorized_keys /home/.ssh/username Create sym...
SSH public keys not working; my home directory is encrypted
1,330,333,166,000
I have an SSD disk with several partitions. One of them is has a btrfs volume, mounted as /home, which holds an ecryptfs home directory. When I trim the volumes, it seems that fstrim doesn't trim data blocks on such volume - why? Below you can see all the informations about the setup, and the procedure I follow, with ...
It is a common misunderstanding to worry about the sizes reported by fstrim. It really doesn't mean anything. Just ignore it. fstrim just issues the appropriate ioctl, everything else is the decision of the filesystem, and filesystems behave very differently. For example, ext4 tries to avoid trimming the same things o...
Why fstrim appears not to trim data blocks on btrfs (+ecrypts)?
1,330,333,166,000
Are there any security related risks when mounting with root privileges compared to mounting with regular users? I have a script which does some ecryptfs mounting with non-root privileges (by design), but it doesn't work as expected on all required Linux systems, so I'm wondering if switching to mounting as root is a ...
Deep down, mounting is performed by root anyway: only root can call the mount system call. Programs such as mount, pmount and fusermount are setuid root and restrict what non-root callers are allowed to mount. If you're mounting a filesystem that doesn't implement file ownership (e.g. FAT), the user calling mount will...
Are there any security risks when mounting as root?
1,330,333,166,000
I'm using ecryptfs for an encrypted home directory. I would like to try out the mount option "ecryptfs_xattr" on my encrypted home directory, because it will probably improve performance. Can I specify this option somewhere, and still have it decrypt the home when I log in? (I assume I have to re-create the encrypted...
First of all, it's extremely doubtful that you'll see a noticeable performance improvement using xattrs for eCryptfs metadata. As for specifying particular mount options, you can sort of do this using the "ALIAS" feature, which I've documented in the mount.ecryptfs_private manpage. Here, you can add some fstab-style ...
Mount options with ecryptfs encrypted home
1,330,333,166,000
Can I decrypt an ecryptfs Private directory from a script? My basic use case for this type of activity is for doing remote backups. Imagine you have a machine (call it privatebox) with an encrypted private directory that stores your photos (or some other sensitive information). It is only decrypted upon logging in. An...
Okay I figured this out. Thanks for your help Xen2050, I don't have enough reputation here to give you an upvote (yet). Here's the bash script that works for me: #Set this variable to your mount passphrase. Ideally you'd get this from $1 input so that the actual value isn't stored in bash script. That would defeat the...
Non-interactive ecryptfs directory encrypt/decrypt
1,330,333,166,000
I have been using ecryptfs encryption for a long time. I prefer per user encryption. That means even a root user can not read a user files when the user is not logged in. When an user is not logged in, any users (including root) should not be able to read his files. But ecryptfs is not an encryption for the entire sys...
This is exactly what I do with my desktop. I have my entire partition encrypted with LUKS. And then I have my home directory encrypted using ecryptfs. The reason I encrypt my home directory using ecryptfs is because the desktop is used by my partner as well. If you are the sole user of your system, ecryptfs may not b...
Is it good to have both LUKS and ecryptfs encryptions at the same time?
1,330,333,166,000
I currently have an unencrypted external hard drive that I use as a backup for my encrypted (with LUKS) main machine. To update my backup, I simply log in to the main machine and rsync to my external hard drive. Clearly, having an unencrypted backup for material that was worth encrypting in the first place is a bad id...
Nowadays cryptsetup itself supports non-destructively transforming an unencrypted partition into a encrypted LUKS device with the reencrypt subcommand. Assuming that your external drive is accessible via /dev/sdX and the current filesystem is located on /dev/sdXY you need first shrink the filesystem to make room for t...
Encrypting a currently used external hard drive such that it can be updated with rsync?
1,330,333,166,000
My system takes exactly 95 seconds to boot: 5 seconds actual boot and 90 seconds waiting for a nonexistent drive: (...boot.log...) A start job is running for dev-disk-by\x2duuid-6bbb4ed8\x2d53ea\x2d4603\x2db4f7\x2d1205c7d24e19.device (1min 29s / 1min 30s) Timed out waiting for device dev-disk-by\x2duuid-6bbb4ed8\x2d53...
The file /etc/crypttab is a (less known) counterpart of fstab for managing crypto filesystems. The default installation of Ubuntu configured an encrypted swapfile: cryptswap1 UUID=6bbb4ed8-53ea-4603-b4f7-1205c7d24e19 /dev/urandom swap,offset=1024,cipher=aes-xts-plain64 Originally I had disabled this swap partition in...
Why does systemd wait for a disk not present in `fstab`?
1,330,333,166,000
I'm using ext4 encryption. https://wiki.archlinux.org/index.php/Ext4#Using_file-based_encryption Before I decrypt a directory, I can see lots of encrypted filenames in it. I would like to copy the encrypted files so that I can decrypt them on a different machine. I could do this with ecryptfs. How do I do this with ...
You can see encrypted & padded filenames, but you should be unable to read file contents. So trying to copy the files unencrypted will result in errors such as: cp: cannot open 'vault/YgI8PdDi8wY33ksRNQJSvB' for reading: Required key not available So you are pretty much not supposed to do this. The practical answer i...
Copying ext4 encrypted files
1,330,333,166,000
On Ubuntu 20.04 - and I have encountered this with (vanilla) GNOME before - with KDE Plasma (no, not Kubuntu!), I am faced with a strange thing that happens every few hours or so and for which I have no explanation or remedy as of yet. Somehow the ecryptfs-encrypted home folder which gets mounted when I log on "disapp...
Well, that's stupid of course, since I "wasted" 200 reputation on a bounty mere hours ago, but I seem to have solved the puzzle. Anyone providing hints what to look out for and try which are more straightforward than mine will get the bounty. Alright, so it turned out that pam_unix from the logs was an important clue....
ecryptfs mounted home folder "disappears" when Samba closes session for my (interactive) user via PAM
1,330,333,166,000
If I enable filename encryption in eCryptfs, when I unmount the filesystem all my files have names which start with "ECRYPTFS_FNEK_ENCRYPTED". I understand the need for the file system to have a signature in the filename which it can use to identify a filename as encrypted, but I would like to use something more disc...
The prefix is a constant in the kernel source: fs/ecryptfs/ecryptfs_kernel.h 188:#define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX "ECRYPTFS_FNEK_ENCRYPTED." 189:#define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 24 It may just be a matter of editing those constants, recompiling the ecryptfs kernel module, and loadin...
Can the eCryptfs encrypted filename prefix be changed?
1,330,333,166,000
i'm new and i hope to find an answer here. Please tell me, if you need more information. I have an disk encryption for my home partition on Linux 4.13.0-43-generic x86_64 (Ubuntu 16.04.4 LTS). Today when I started the laptop, I got the message, that my disk is full and there is no available space any more. With the di...
/home/.ecryptfs/bianca/.Private contains the encrypted versions of all your home files, when you're logged in they're decrypted on-the-fly to your home (~ or /home/bianca). It should be approximately the same size as your home when you're logged in. Delete (or backup/move) some files out of your home, not directly fro...
Disk encryption with ecryptfs - full disk
1,330,333,166,000
I have an embedded Linux system with unencrypted kernel image and initramfs in NAND flash. My RootFS is in SD card. I want to encrypted some files on SD Card as my SD card is easily accessible physically. For this I am planing to use eCryptfs. But I want to keep the keys inside NAND flash in kernel image or initramfs....
If you didn't have an initramfs, you could do it with kernel parameters. Just add a random string as kernel parameter and then use /proc/cmdline as the key for your encryption. If it's not easy to add such parameters to your boot loader, the Linux kernel has a CMDLINE config option that lets you compile it in. (Note: ...
eCryptfs key in kernel image or initramfs
1,330,333,166,000
Is it possible to setup ecryptfs mounts to prompt for password upon bootup? Say for example /home and /var are ecryptfs folders that need to be mounted; how do I force a prompt upon bootup to ask for mount passwords?
Solution is to use luks/dm-crypt and then modify /etc/crypttab file to do what I need.
Bootup prompt for ecryptfs password
1,330,333,166,000
I have encrypted my home disk a long time ago and I configured pam to mount it automatically on login. However after update to version 1.1.5-3 pam is not mounting the disk anymore. Here are the logs : PAM adding faulty module: /usr/lib/security/pam_ecryptfs.so pam_unix(login:session): session closed for user ben PAM u...
In ecryptfs-utils 96-1 the file pam_ecryptfs.so is installed in /lib/security (click) which was changed in ecryptfs-utils 96-2 to /usr/lib/security (click). You might just need to update your system.
Pamd not mounting ecryptfs disk anymore since upgrade
1,330,333,166,000
I tried to install eCryptfs on my server to open an eCryptfs I did on my home computer. I got these errors. $ sudo mount -t ecryptfs /home/(place)/enc/ /home/(place)/enc/ Unable to get the version number of the kernel module. Please make sure that you have the eCryptfs kernel module loaded, you have sysfs mount...
It seems that OpenVZ is the problem (again). OpenVZ uses the parent kernel and I can't do anything with that.
Cannot mount eCryptfs
1,330,333,166,000
Recently, we've rebooted server and got ecryptfs mount fail: ... Signature not found in user keyring Perhaps try the interactive 'ecryptfs-mount-private' user@host:~$ Could that be because of password change? Although, 1. There's no mount password 2. We might have login password When trying to recover mount d...
I set up an ecryptfs private folder, then removed the r & w permission from the wrapped-passphrase file to test... If you had checked the syslog right after seeing the message Info: Check the system log for more information from libecryptfs You would have seen lines like this: Jan 15 00:21:48 sys ecryptfs-insert-wrap...
"ecryptfs-mount-private" returns "fopen: No such file or directory"
1,515,991,255,000
I want accomplish the following task: On a Ubuntu System with multiple Users accounts and encrypted Home directorys a NFS share should be mounted after login. I want to use systemd user service for this, but can't get it fully working. What's working so far: - manual mount with user rights, configured with sudo - en...
It's a bug in the ecryptfs package configuration. You can use a quick fix: Open /etc/pam.d/common-session and switch the lines session optional pam_systemd.so session optional pam_ecryptfs.so unwrap to session optional pam_ecryptfs.so unwrap session optional pam_systemd.so so that pam_sy...
Use Systemd user services with ecryptfs
1,515,991,255,000
I needed to reinstall ubuntu on my hard drive because I think I corrupted some files and it wasn't booting up (I know, it was very stupid). I tried to reinstall from a LiveCD by checking the "keep the files" option. Unfortunately, I did this kind of carelessly, where when it asked me for the username and password for ...
Using a Live CD was the only thing I hadn't tried and turned out that worked. I'm not sure why it was necessary though. It was only a directory that was encrypted, so it feels like it should have been able to decrypt it. Anyway, if you are stuck like I was, then that should probably do it.
Cannot recover encrypted files on Ubuntu
1,515,991,255,000
I've recently installed Ubuntu 12.04 LTS (minimal virtual machine) on a VPS host. I've encrypted the virtual disk and encrypted the home directory of my main user account, that I'm using to access the install through SSH (using public key authentication). So far, so good. The thing is: I can't figure out what exact a...
Situation: you have an encrypted home directory. Step 1: you log in over SSH. Your encrypted data is not mounted, so what you see is your “real” home directory on the (unencrypted) main filesystem. This home directory doesn't contain much that's directly usable: ~/.ecryptfs/ contains control data for your encrypted d...
What makes the files in my home directory appear, when I log in through SSH then run ecryptfs-mount-private?
1,515,991,255,000
I recently powered on some old notebook with Linux Mint 11 (Katya) installed, and I thought I remembered my user password, but turns out I didn't. So I reset that password using the instructions here. After doing that, I could login successfully with my new password, but right after that I got a series of error messag...
It is absolutely essential that you record your randomly generated mount passphrase, without which it's impossible to recover your data. I can't stress that more strongly :-) You should write this down, or print it out and store it somewhere safe. Alternatively, you might consider using the zEscrow service from Gazza...
I reset my password and now I can login, but without nautilus or program menu
1,515,991,255,000
I used ecryptfs-migrate-home to encrypt my home folder on my Debian (Testing) system. As I am a complete encryption-greenhorn, I don't know yet how to check, if the encryption succeeded. However, I suppose encryption works but filenames are not encrypted. I want to have encrypted filenames as well. How can I get encry...
The encrypted home utilities don't support the ability to enable encrypted filenames after you've set up your encrypted home directory. But, I looked at the ecryptfs-migrate-home script and believe that it should be enabling filename encryption by default. Let's verify that filename encryption is enabled. Do you have ...
setup filename encryption for encrypted home folder in eCryptfs
1,515,991,255,000
After an update and a reboot, my ecryptfs home directory in Linux is failing to decrypt and mount on boot. It caused a bit of a panic, as Mint seemed entirely reinstalled from scratch (but the contents of /usr/ are still there and the wifi is still configured, so that's how I know it was just the home dir that was aff...
After trying to diagnose what happened, the most likely cause would be a bad SSD trim. Or solar rays. Not sure. Run journalctl | grep fstrim to check. This is what I did and I had a weekly trim that happened ~3h before the fateful reboot. For others who might come across this, boot from live USB, mount/decrypt your ho...
Encrypted home dir suddenly failing to mount on boot
1,515,991,255,000
I have installed Fedora, but used existing /home partition from previous Ubuntu install: partitions: /boot/efi, / (formatted during install), /home (kept from Ubuntu), user was set-up with same username and password as I had on Ubuntu install. After installation, I couldn't login. So, I installed packages ecryptf...
It was SELinux issue. I solved it by setting up proper security contexts for home and ecryptfs stuff. Run this with unmounted ecryptfs home: chcon -u unconfined_u -t user_home_dir_t /home/<username>/ chcon -u unconfined_u -t ecryptfs_t /home/.ecryptfs/<username>/.ecryptfs/ chcon -u unconfined_u -t ecryptfs_t /home/.ec...
How to automatically `ecryptfs-mount-private` on `gdm` login in Fedora 27?
1,515,991,255,000
I recently got an SSD. I use it to store my / as well as my /home directories (on different partitions). For each user, I would like to have most of their folders on my big RAID-1 with 2 hard drives (I'm talking about /home/<user>/Downloads, /home/<user>/Music, /home/<user>/Documents, etc. to make this more clear). Fi...
I found a solution. Yet it is not perfect, but I think it can be improved. Basically I did what @rcoup suggested here: https://askubuntu.com/questions/103835/securely-automount-encrypted-drive-at-user-login/165451#165451 On debian for some reason mount.ecryptfs_private is in /sbin/. One can access mount.ecryptfs_priva...
have /home/user/Downloads (and other user folders) on a different partition
1,319,313,753,000
What can you do with the eval command? Why is it useful? Is it some kind of a built-in function in bash? There is no man page for it..
eval is part of POSIX. It's an interface which can be a shell built-in. It's described in the "POSIX Programmer's Manual": http://www.unix.com/man-page/posix/1posix/eval/ eval - construct command by concatenating arguments It will take an argument and construct a command of it, which will then be executed by the shel...
What is the "eval" command in bash?
1,319,313,753,000
In order to run ssh-agent I have to use: eval $(ssh-agent) Why is it necessary to eval the output of ssh-agent? Why can't I just run it?
ssh-agent outputs the environment variables you need to have to connect to it: shadur@proteus:~$ ssh-agent SSH_AUTH_SOCK=/tmp/ssh-492P67qzMeGA/agent.7948; export SSH_AUTH_SOCK; SSH_AGENT_PID=7949; export SSH_AGENT_PID; echo Agent pid 7949; shadur@proteus:~$ By calling eval you immediately load those variables into y...
Why eval the output of ssh-agent?
1,319,313,753,000
The bash manual states: eval [arg ...] The args are read and concatenated together into a single com- mand. This command is then read and executed by the shell, and its exit status is returned as the value of eval. If there are no args, or only null arguments, eval returns...
When you do the following - `nonsense` echo $? You basically are asking "Tell me the exit status when I try to get the output of the command nonsense" the answer to that is "command not found" or 127 But when you do the following eval `nonsense` echo $? You are asking "tell me the exit status of eval when I evalua...
return value from eval
1,319,313,753,000
I've been using docker for a while and there's a command I write each time I boot up my docker: eval $(docker-machine env) I know eval shouldn't be used unless necessary, but it's mentioned by the following: docker-machine env outputs environment variables like this: docker-machine env export DOCKER_TLS_VERIFY="1" ex...
Enclose your alias in single quotes instead of double quotes. alias dockereval='eval $(docker-machine env)' Double quotes allow expansion of variable (in bash at least) while single quotes don't
How to save an alias of an eval $(other_comand) command
1,319,313,753,000
As I was looking this answer https://stackoverflow.com/a/11065196/4706711 in order to figure out on how to use parameters like --something or -s some questions rised regarding the answer's script : #!/bin/bash TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \ -n 'example.bash' -- "$@"` if [ $? != 0 ] ; the...
One of the many things that getopt does while parsing options is to rearrange the arguments, so that non-option arguments come last, and combined short options are split up. From man getopt: Output is generated for each element described in the previous section. Output is done in the same order as the elements are spe...
Bash: Why is eval and shift used in a script that parses command line arguments?
1,319,313,753,000
Consider the commands eval false || echo ok echo also ok Ordinarily, we'd expect this to execute the false utility and, since the exit status is non-zero, to then execute echo ok and echo also ok. In all the POSIX-like shells I use (ksh93, zsh, bash, dash, OpenBSD ksh, and yash), this is what happens, but things get ...
That no other shell needs such workaround is an strong indication that it is a bug in OpenBSD ksh. In fact, ksh93 doesn't show such issue. That there is a || in the command line must avoid the shell exit caused by an return code of 1 on the left side of it. The error of an special built-in shall cause the exit of a no...
Behaviour of "eval" under "set -e" in conditional expression
1,319,313,753,000
I have the following file variable and values # more file.txt export worker01="sdg sdh sdi sdj sdk" export worker02="sdg sdh sdi sdj sdm" export worker03="sdg sdh sdi sdj sdf" I perform source in order to read the variable # source file.txt example: echo $worker01 sdg sdh sdi sdj sdk until now every thing is perfec...
You have export worker01="sdg sdh sdi sdj sdk", then you replace = with a space to get export worker01 "sdg sdh sdi sdj sdk". The space separated fields in that are export, worker01, "sdg, sdh, etc. It's probably better to split on =, and remove the quotes, so with just the shell: $ while IFS== read -r key val ; do ...
bash + read variables & values from file by bash script
1,319,313,753,000
What is the difference between using: eval 'echo "foo"' and echo 'echo "foo"' | bash is there any?
Short Answer The command run by eval is executed in the current shell and the command piped to bash is executed in a sub-shell, e.g.: > echo 'x=42' | bash; echo $x > eval 'x=42'; echo $x 42 Longer Answer In the comments the claim was made that in more recent versions of bash (>=4.2) the first command could also have...
eval vs. pipe through bash
1,319,313,753,000
I have a bash shell variable containing a string formed of multiple words delimited by whitespace. The string can contain escapes, such as escaped whitespace within a word. Words containing whitespace may alternatively be quoted. A shell variable that is used unquoted ($FOO instead of "$FOO") becomes multiple words bu...
Use read: read -a ssh_args <<< "${SSH_ORIGINAL_COMMAND}" set -- "${ssh_args[@]}" This will parse words from SSH_ORIGINAL_COMMAND into the array ssh_args, treating backslash (\) as an escape character. The array elements are then given as arguments to set. It works with an argument list passed through ssh like this: $...
Can bash expand a quoted and/or escaped string variable into words?
1,319,313,753,000
I have the following example. #!/bin/bash ARGUMENTS="-executors 1 -description \"The Host\" " # call1 # error: parameter Host" is not allowed java -jar swarm-client.jar $ARGUMENTS # call2 # works fine with eval eval java -jar swarm-client.jar $ARGUMENTS In $ARGUMENTS, I have a quoted argument. I do not underst...
You don't pass quoted arguments to a command, you pass arguments. When you enter: cmd arg1 arg2 The shell parses that line in its own syntax where space is a word delimiter and calls cmd1 with cmd, arg1 and arg2 as arguments. Note: cmd does not receive any space character in its arguments, the spaces are just operat...
Why is using eval necessary to pass quoted arguments
1,319,313,753,000
I encountered a strange bug today, when running a script in a directory containing a directory with parentheses in it, such as a(). Minimal working example I managed to reduce the bug to the following minimal working example: Create an empty directory in /tmp and cd into it: mkdir /tmp/foo cd /tmp/foo Create a script...
This is neither strange nor a bug in bash (it does seem to be a bug in /usr/share/modules/init/bash though). You are using an unquoted command substitution together with eval. The string that is the result of the command substitution will, since it is unquoted, undergo word splitting and filename expansion (globbing...
File with parentheses/brackets in working directory causes eval error
1,319,313,753,000
I'm trying to use eval command to eval a comment -- I'm not sure if this is the right way to do it. Example: i=?? (What I want here is either a #, to comment what's after, or blank) somecommand arg1 arg2 $(eval $i) >> file So based on the $i value it has to be either: somecommand arg1 arg2 # >> file as of "Don't print...
You could always do: unset -v log # or log=true ([ -z "$log" ] || exec >> file1; somecommand arg1 arg2) ([ -z "$log" ] || exec >> file2; somecommand arg1 arg2) Or: if [ -n "$log" ]; then exec 3>> file1 4>> file2 else exec 3>&1 4>&1 fi somecommand arg1 arg2 >&3 somecommand arg1 arg2 >&4 Or: log() { local output...
How to conditionally redirect the output to files based on variable in bash
1,319,313,753,000
I want a script to make awk to become an interactive mathematical calculator, to eval mathematical expressions given in each line. I.e., instead of constructing awk commands to calculate expressions like the following: $ awk 'BEGIN{print 180/1149}' 0.156658 $ awk 'BEGIN{print (150+141)/1149}' 0.253264 I want my scri...
The arithmetic evaluation is done as part of the awk/perl language evaluation. perl has a eval to evaluated arbitrary strings as perl code at runtime, so you can do: perl -lne 'print eval $_' But awk doesn't (though in the case of GNU awk, its debugger does, see below), so you'd need to run awk for each line of input...
awk or perl to eval mathematical expressions in each line
1,319,313,753,000
With bash >5, I'm trying to assign a different value to variables depending on the architecture specified in a variable. I use a function to do so. This works perfectly: # arguments: variable name to assign, value for mac arch, value for pi arch create_variable_for_arch() { if [ "$_run_for_arch" = "mac" ]; th...
declare (like the typeset of other shells; also understood by bash as an alias for declare) declares a variable in the current scope (and can set a type and/or value). So here, you would declare a variable that is local to the create_variable_for_arch function. When that function returns, that variable would be gone....
Why does substituting eval with declare (for creating dynamic variables) result in an empty variable?
1,319,313,753,000
I have a small script with the following lines echo mom,dad |awk -F, '{print $1,$2}' | while read VAR1 VAR2 do for i in VAR1 VAR2 do eval X=\$$i echo $X done done OUTPUT: mom dad What is this line doing eval X=\$$i? I understand the rest of the lines, but I don't understand the iterations of this for loo...
eval performs an extra level of substitution and processing on the remainder of the line. In the first iteration of the loop, i is set to "VAR1", and one level of backslash-escaping is reduced, so: eval X=\$$i becomes: X=$VAR1 which evaluates to: X=mom (repeat for the next loop, only $i is then VAR2, and $VAR2=dad)...
What does eval X=\$$i mean in UNIX?
1,319,313,753,000
I need a lot of different aliases to create ssh tunnels to different servers. To give you a few of them: alias tunnel_1='autossh -M 20000 -N -L 8080:localhost:8080 -N -L 9200:localhost:9200 -N -L 8090:localhost:8090 [email protected]' alias tunnel_2='autossh -M 20000 -N -L 8000:localhost:8080 -N -L 9200:localhost:9200...
Use a single shell function: tunnel () { local host="$1"; shift local port local args args=( -M 20000 ) for port do args+=( -N -L "$port:localhost:$port" ) done autossh "${args[@]}" "$host" } or, for /bin/sh: tunnel () { host="$1"; shift for port do set -- "$@" ...
building an alias from a function
1,319,313,753,000
Suppose: a=b; b=c; c=d Then eval echo \$$a produces the output: c If we want to extract the output d using just input a, I tried the following way: (i) eval echo \$(eval echo \$$a) produces the error: syntax error near unexpected token '(' (ii) eval echo \$\(eval echo \$$a\) produces the output: c I am not able to...
First, a word of caution: From a security standpoint, it's a really bad idea to use eval in any shell script unless you know exactly what you're doing. (And even then, there are virtually zero instances where it is actually the best solution.) As a beginner to shell scripting, please just forget that eval even exists....
Using the eval command twice
1,319,313,753,000
I would like to get, in the output, the content of KW0_TEXT and KW1_TEXT from the "for" of this script: #!/bin/sh STRS=" KW0 KW1 " KW0_TEXT="text text text" KW1_TEXT="text text text text" for str in ${STRS}; do echo ${str}_TEXT eval echo ${str}_TEXT done so far, in the output, I got only: KW0_TEXT KW0_TEXT KW1_TEXT...
If your /bin/sh is actually /bin/bash, you can use variable indirection: #!/bin/bash STRS=" KW0 KW1 " KW0_TEXT="text text text" KW1_TEXT="text text text text" for str in ${STRS}; do var=${str}_TEXT printf "%s\n" "${!var}" done
Get contents of passing string from a script
1,319,313,753,000
I was checking .bashrc to set colors for ls comand and found this export SHELL='/bin/bash' export LS_OPTIONS='--color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' Will there be any problem if i use dircolors instead of using it with eval? What's the difference?
Neither eval dircolors nor dircolors will work. What you need is: eval "$(dircolors)" (or the ancient form eval "`dircolors`") That is, you need to evaluate the output of dircolors. dircolors outputs code to be evaluated by the shell like: LS_COLORS='...' export LS_COLORS That's the code you want to evaluate. eval d...
Will "dircolors" work here instead of " eval `"dircolors`"` "?
1,319,313,753,000
I wish to execute different commands and check the return code afterwards before moving to the next steps in the script. At the same time I also wish to log the output of the executed commands to a file using the tee command. Example: #set non-existing folder local_path="~/njn" log_path_file="test.log" cmd="ls -l ${lo...
After some additional testing, I've reached this code switch is wrapped nicely and returns the executed command return code. The code which @Freddy have posted is nearly complete. The return code is exported inside the function but is not exported outside it. The use of the shopt -s lastpipe was taken from this page: ...
Get return code of first piped command using eval?
1,319,313,753,000
I have a little ugly bash script on my Ubuntu machine that contains the lines: search_command="find -L $(printf "%q" "$search_folder") \( ! -regex '.*/\..*/..*' \) -mindepth 1 2> /dev/null" for i in "${IGNOREENDINGS[@]}" do search_command="$search_command -not -name \"*$i\"" done search_command="$search_command | ...
There are two possibilities here: either fzf is not actually exiting when you select a file, or find is not exiting when fzf does. If it's the latter one, you can write a script to close find manually when fzf exits. The way that pipes work in Linux, find does not know that the pipe it is writing to has nothing readin...
Bash: How to kill eval if the process that receives its output terminates
1,319,313,753,000
In trying to make my .zshrc neater, I stumbled over the following problem/question: "How can I run the output of another command?". While I'm sure this is a simple problem, I just don't understand what I'm doing wrong. I want to add pip-completion to my config. For this, I need to add the output of $ pip completion --...
You need to run eval "$(pip completion --zsh)" Compare the output of these two commands: echo $(pip completion --zsh) echo "$(pip completion --zsh)" In zsh, $VARIABLE means “take the value of VARIABLE unless it's empty”. But $(command) means “take the output of command and break it into words at whitespace”. So in e...
Evaluate multi-line output (with comments) of another command. (pip-completion)
1,319,313,753,000
When use eval on a command, does eval apply the shell twice to the redirection part of the command? Suppose the filename in the redirection contains a whitespace, if eval applies all the steps of parsing, shell expansions and word splitting and other steps to it more than once, the filename will be split into two wor...
In the example you provide, the only thing eval is getting is cat, the redirection is happening outside the eval and the file is being provided as stdin for the eval "cat" command. One variation is to quote the whole command, including the redirection, using single quotes: $ eval 'cat < "$filename"' hi Now eval is ge...
Does `eval` apply the shell to the redirection part of the following command?
1,319,313,753,000
I am writing a script which accepts two arguments: #! /bin/bash eval for i in {$1..$2}; do echo $i; done I run it like: $ ./myscript 0002 0010 syntax error near unexpected token `do' Why is the error? I though it might be because the looping should be grouped. But by replacing eval for i in {$1..$2}; do echo $i...
That's because the shell evaluated ;, so eval didn't see it. You have to escape any shell special character to delay its evaluation and pass is literally to eval: eval for i in \{"$1".."$2"\}\; do echo \"\$i\"\; done
Error when eval a for-loop
1,319,313,753,000
Consider the following: $ a='friend' $ b='printf "%s\n" "$a"' $ eval "$b" friend This should be completely safe. Let's however say that $b is the same but $a is unknown. Are there any security implications then to eval "$b" and if so, what can I do to mitigate them?
If b contains the literal string printf "%s\n" "$a", i.e. you didn't expand $a into it before hand, then yes, eval "$b" should be fine. Not sure why you'd need eval there, though, since you just have a static command. Just run printf "%s\n" "$a" directly. You said in comments you want to store some commands for future...
Security implications of executing strings using eval in bash
1,319,313,753,000
Why does this produces _results=""... _results="$( grep ${_gopts[@]} )" And this produces the desired _results (list of SSHFS entries in fstab)... _results="$( eval grep ${_gopts[@]} )" The _gopts array is identical in both cases and consists of... declare -p _gopts declare -a _gopts=([0]="--extended-regexp" [1]="--...
Because of the extra quotes around the 5th element (the regexp: [5]="'^[^#]*sshfs#'"). The grep command will be passed an argument of the form '^regex' instead of ^regex, which will not match, ever (there's no way for regex to both follow a single quote and start at the beginning of the line, at the same time). Remove...
Why does this bash idiom require eval?