Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

3 votes
2 answers
5614 views
The tilde key generates "k", not "~"
I am using an Acer Swift One laptop with Windows 10. The keyboard is a standard German keyboard. I downloaded `bash` today from [git-scm.com/download/win][1] and tried some commands. For some reason `bash` shows `k` instead of `~` when pressing the tilde key. Any help or advice on what I'm doing wro...
I am using an Acer Swift One laptop with Windows 10. The keyboard is a standard German keyboard. I downloaded bash today from git-scm.com/download/win and tried some commands. For some reason bash shows k instead of ~ when pressing the tilde key. Any help or advice on what I'm doing wrong?
Linda (39 rep)
Feb 8, 2020, 11:30 AM • Last activity: Jun 23, 2025, 02:04 PM
-3 votes
1 answers
78 views
Need working examples of using tilde expansion immediately following the : (colon) sign in variable assignment
In the Bash manual, it is written about the tilde expansion: > Each variable assignment is checked for unquoted tilde-prefixes > immediately following a ‘:’ or the first ‘=’. [Read the Bash manual about tilde expansion.][1] [1]: https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html...
In the Bash manual, it is written about the tilde expansion: > Each variable assignment is checked for unquoted tilde-prefixes > immediately following a ‘:’ or the first ‘=’. Read the Bash manual about tilde expansion. I assumed that the : sign when assigning a variable is related to parameter expansion and instructed one of the popular AIs to find examples that satisfy the conditions defined in the Bash manual. The summary of his response is as follows: - There isn't a valid working example with the tilde immediately following the : without additional characters.
Kiki Miki (27 rep)
Feb 12, 2025, 12:07 PM • Last activity: Feb 13, 2025, 04:15 AM
16 votes
2 answers
8478 views
Expansion of tilde in zsh
I stumbled upon this behavior of zsh when using FreeBSD: % dd if=/dev/zero bs=1M count=1 of=~/test2 dd: failed to open '~/test2': No such file or directory This really confused me because the same thing works just fine in bash. I can `touch` files using tilde in zsh, and then `ls` them: % touch ~/te...
I stumbled upon this behavior of zsh when using FreeBSD: % dd if=/dev/zero bs=1M count=1 of=~/test2 dd: failed to open '~/test2': No such file or directory This really confused me because the same thing works just fine in bash. I can touch files using tilde in zsh, and then ls them: % touch ~/test2 % ls ~/test2 /home/christoph/test2 At first, I assumed that zsh doesn't realize that there comes a path after of= so it didn't expand ~. But autocompleting file names works just fine. In fact, if use an existing file name, begin its path with ~, and then hit Tab at some point, the path gets expanded in the command I'm typing in. Why does zsh pass ~/test2 to dd, not /home/christoph/test2? zsh behaves the same on Linux. In fact, I executed these commands above and copied their outputs on a Linux machine.
UTF-8 (3377 rep)
Jun 26, 2017, 06:13 PM • Last activity: Jun 26, 2024, 12:49 PM
1 votes
2 answers
115 views
How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression?
For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all directories: ```shell sudo find ~/bin /home/samokat/.local/bin /home/samokat/bin /usr/local/sbin /usr/local/...
For example, I want to find all symlinks that reference to particular binary in all directories that belong to system $PATH. This can be successfully achieved with manual specification of all directories:
sudo find ~/bin /home/samokat/.local/bin /home/samokat/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin -lname /opt/openoffice4/program/soffice
But when I'm trying to use command with $PATH expansion:
sudo find echo $PATH | tr ':' ' ' -lname /opt/openoffice4/program/soffice
I get error and result:
find: ‘~/bin’: No such file or directory
/usr/bin/soffice.link-to-openoffice-bak
echo $PATH | tr ':' ' '
outputs correct path:
~/bin /home/samokat/.local/bin /home/samokat/bin /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /snap/bin
The following also are not working:
sudo find echo $PATH | tr ':' ' ' | xargs -lname /opt/openoffice4/program/soffice
sudo find { echo $PATH | tr ':' ' ' | xargs } -lname /opt/openoffice4/program/soffice
sudo find eval "echo $PATH | tr ':' ' ' | xargs" -lname /opt/openoffice4/program/soffice
echo $PATH | tr ':' ' ' | xargs | sudo find -lname /opt/openoffice4/program/soffice  # runs some long computation
How to pass starting point directories as calculable parameter to find? Does this possible?
Anton Samokat (289 rep)
Apr 11, 2024, 02:19 PM • Last activity: Apr 11, 2024, 08:07 PM
0 votes
1 answers
50 views
Accents don't work for me in Google Chrome
The __accent keys__, both normal and the inverted tilde, do not work for me in __Google Chrome__. I don't know how to solve it, among other things, I read that some program may be interfering, but I don't believe it. - __Versión 122__.0.6261.128 (Build oficial) (64 bits) How do I solve this? ``...
The __accent keys__, both normal and the inverted tilde, do not work for me in __Google Chrome__. I don't know how to solve it, among other things, I read that some program may be interfering, but I don't believe it. - __Versión 122__.0.6261.128 (Build oficial) (64 bits) How do I solve this?
xev
KeyPress event, serial 48, synthetic NO, window 0x2200001,
    root 0x408, subw 0x0, time 68079885, (48,-1), root:(1110,25),
    state 0x10, keycode 48 (keysym 0xfe51, dead_acute), same_screen YES,
    XLookupString gives 2 bytes: (c2 b4) "´"
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: True

KeyPress event, serial 48, synthetic NO, window 0x2200001,
    root 0x408, subw 0x0, time 68256708, (25,1), root:(1087,27),
    state 0x10, keycode 34 (keysym 0xfe50, dead_grave), same_screen YES,
    XLookupString gives 1 bytes: (60) "`"
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: True
**ps -fe:**
ps -s
 ~ 
ps -s
  UID     PID          PENDING          BLOCKED          IGNORED           CAUGHT STAT TTY        TIME COMMAND
    0   17410 0000000000000000 0000000000000000 0000000000301000 00000000080b6a07 S+   tty1       0:00 sudo su
    0   17411 0000000000000000 0000000000000000 0000000000301000 0000000000096a07 Ss   pts/3      0:00 sudo su
    0   17412 0000000000000000 fffffffe7ffb9eff 0000000000000000 0000000000004000 S    pts/3      0:00 su
    0   17413 0000000000000000 0000000000010000 0000000000384004 000000004b813efb S    pts/3      0:00 sh
    0   17506 0000000000000000 0000000000000000 0000000000001000 0000000100004003 Sl   pts/3      0:40 pcmanfm --desktop --profile LXDE
    0   30657 0000000000000001 0000000000000000 0000000000001000 0000000100004000 Z    pts/3      0:06 [geany] 
    0   51012 0000000000000000 0000000000000000 0000000000001000 0000000100004003 Sl   pts/3      0:00 pcmanfm --desktop --profile LXDE
    0   52527 0000000000000000 0000000000000000 0000000000301000 00000000080b6a07 S+   pts/3      0:00 sudo su
    0   52528 0000000000000000 0000000000000000 0000000000301000 0000000000096a07 Ss   pts/4      0:00 sudo su
    0   52529 0000000000000000 fffffffe7ffb9eff 0000000000000000 0000000000004000 S    pts/4      0:00 su
    0   52530 0000000000000000 0000000000010000 0000000000384004 000000004b813efb S    pts/4      0:00 sh
    0   52680 0000000000000000 0000000000000000 0000000000001000 0000000100004003 Sl   pts/4      0:06 pcmanfm --desktop --profile LXDE
    0   66566 0000000000000001 0000000000000000 0000000000001000 0000000100004000 Z    pts/4      0:05 [geany] 
    0   69098 0000000000000000 0000000000010000 0000000000000004 0000000000010002 S+   pts/4      0:00 /bin/sh /bin/x
    0   69137 0000000000000000 0000000000000000 0000000000000000 0000000000007207 S+   pts/4      0:00 /usr/bin/xinit /root/.xinitrc -- -br -nolisten tcp
    0   69138 0000000000000000 0000000000000000 0000000000301000 00000001418066ef S
ArtEze (137 rep)
Apr 1, 2024, 01:45 AM • Last activity: Apr 1, 2024, 03:14 AM
1 votes
0 answers
119 views
Incorrect folder name created when using cp command in bash
I would like to copy a file from one location to another. When I use the `cp` command in a terminal it works well, for example I use the following command: cp -r projects/Test/ projects/Personal/ This leads to a creation of the folder `Test` in the folder `Personal` containing all contents of `Test`...
I would like to copy a file from one location to another. When I use the cp command in a terminal it works well, for example I use the following command: cp -r projects/Test/ projects/Personal/ This leads to a creation of the folder Test in the folder Personal containing all contents of Test in the folder projects. However when I execute the same line in a bash file, instead of having a folder named Test in Personal I have a folder named ~. The contents of the file are correct. Would you know how I could have the folder named Test instead of ~? This is the code of my bash file:
#!/bin/sh
cp -r projects/Test/ projects/Personal/
user601459 (19 rep)
Feb 9, 2024, 07:41 AM • Last activity: Feb 9, 2024, 01:21 PM
0 votes
2 answers
78 views
Ubuntu doesn't translate /home/testuser to ~
In Ubuntu 22.04.3 LTS, if I log in with the credentials of the LDAP user `testuser`, in several different programs the path of the `$HOME` directory is not replaced by `~` (as instead it happens for local users). A couple of examples: 1) In `bash`, the value of `PS1` is the default one: \[\e]0;\u@\h...
In Ubuntu 22.04.3 LTS, if I log in with the credentials of the LDAP user testuser, in several different programs the path of the $HOME directory is not replaced by ~ (as instead it happens for local users). A couple of examples: 1) In bash, the value of PS1 is the default one: \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ but it appears as testuser@myhost:/home/testuser$ instead of testuser@myhost:~$ 2) In neomutt, in the left column where the mail directories are listed, their full path appears /home/testuser/Mail/mailbox1 instead of ~/Mail/mailbox1 However, in bash, $ echo $HOME /home/testuser so the env variable HOME is somewhat recognized. What could it be the problem? ---------- **Update** I am using sssd to manage the authentication of the LDAP users: $ grep passwd /etc/nsswitch.conf passwd: files systemd sss The entries of the LDAP user and of a local user look very similar: $ getent passwd testuser testuser:*:::Test User:/home/testuser/:/usr/bin/bash $ getent passwd localuser localuser:x:::,,,:/home/localuser:/bin/bash And $ echo $HOME /home/testuser/ matches the home directory specified in getent passwd testuser.
BowPark (5155 rep)
Jan 10, 2024, 02:44 PM • Last activity: Jan 17, 2024, 11:21 PM
0 votes
1 answers
56 views
Bash script variable syntax: with some commands it works, with others it does not
I do not understand the behaviour of this variable: SSH_CONFIG_FILE="~/.ssh/config" echo $SSH_CONFIG_FILE ls -l $SSH_CONFIG_FILE ls -l ~/.ssh/config This is the output: ~/.ssh/config ls: cannot access '~/.ssh/config': No such file or directory -rw------- 1 pm domain^users 1229 Sep 19 10:52 /home/pm/...
I do not understand the behaviour of this variable: SSH_CONFIG_FILE="~/.ssh/config" echo $SSH_CONFIG_FILE ls -l $SSH_CONFIG_FILE ls -l ~/.ssh/config This is the output: ~/.ssh/config ls: cannot access '~/.ssh/config': No such file or directory -rw------- 1 pm domain^users 1229 Sep 19 10:52 /home/pm/.ssh/config Why does echo work with the $ notation, and ls does not? I tried surrounding the variable with "", '', ``, {}, [] with no improvement.
Pietro (663 rep)
Sep 19, 2023, 02:24 PM • Last activity: Sep 19, 2023, 02:36 PM
3 votes
2 answers
3179 views
How does the tilde expansion work within a shell variable?
I came across something funny when testing my script. I can ls my directory from the shell manually if I run $ ls ~/db_backups/ test1 test2 $ However, if I assign a shell variable a dir location as such with the tilde, it doesn't work. I tried this with both single and double quotes. $ backupfolder=...
I came across something funny when testing my script. I can ls my directory from the shell manually if I run $ ls ~/db_backups/ test1 test2 $ However, if I assign a shell variable a dir location as such with the tilde, it doesn't work. I tried this with both single and double quotes. $ backupfolder='~/db_backups' $ echo $backupfolder ~/db_backups $ ls $backupfolder ls: cannot access '~/db_backups': No such file or directory $ What is happening with the tilde substitution inside the shell variable? Why can't I ls the directory thru the variable like I can manually with the tilde in the dir name?
Classified (529 rep)
Jul 14, 2022, 07:08 PM • Last activity: Jul 16, 2022, 06:08 AM
1 votes
2 answers
549 views
Tilde not returning home directory
After sudo command to change user, Tilde (~) not returning current user's home directory but returning previous login user's home directory. I needed to expand with `echo ~USERNAME` but I need to make `echo ~` to keep compatibility existing apps. ``` user1@server1:-$ whoami user1 user1@server1:-$ su...
After sudo command to change user, Tilde (~) not returning current user's home directory but returning previous login user's home directory. I needed to expand with echo ~USERNAME but I need to make echo ~ to keep compatibility existing apps.
user1@server1:-$ whoami
user1
user1@server1:-$ sudo -u user2 -s /bin/bash
user2@server1:-$ whoami
user2


user2@server1:- echo ~
/home/user1
user2@server1:-$ echo ~user2
/home/user2
Jaswanthi Kolla (11 rep)
May 3, 2022, 10:48 PM • Last activity: May 3, 2022, 11:04 PM
0 votes
1 answers
19378 views
chmod 400 command returning "No such file or directory" error. Trying to launch an instance through AWS
CODE: root@crane-linux:/home/crane/Downloads# sudo chmod 400 ~/home/crane/Downloads/mykey.pem chmod: cannot access '/root/home/crane/Downloads/mykey.pem': No such file or directory root@crane-linux:/home/crane/Downloads# ls discord-0.0.1.deb mykey.pem torguard-latest-amd64.deb root@crane-linux:/home...
CODE: root@crane-linux:/home/crane/Downloads# sudo chmod 400 ~/home/crane/Downloads/mykey.pem chmod: cannot access '/root/home/crane/Downloads/mykey.pem': No such file or directory root@crane-linux:/home/crane/Downloads# ls discord-0.0.1.deb mykey.pem torguard-latest-amd64.deb root@crane-linux:/home/crane/Downloads# Someone please help. I am having trouble with chmod not recognizing my file. I am using the provided tutorial to launch an instance through aws, but I keep getting a "No such file or directory" error, but as you can see when I did ls, the file does exist. Am I missing something here? Ive tried googling for the answer and tried entering the command in a bunch of different formats, but I keep getting the same problem. No one said this would be easy.... P.S. I dont know how to make the quote box show up without the word "quote" like I see people do when they share something from the console. Its probably something simple IM just looking over but....
CulturedI Crane (13 rep)
Mar 12, 2017, 07:06 PM • Last activity: Jan 29, 2022, 09:33 PM
5 votes
1 answers
1093 views
Tilde expansion vs. variables in Bash
Please, consider the following snippet: ``` $ export xx=foo $ sudo bash -c 'echo $xx ~' /root ``` Which is ok. We can't see xx. However, if I expose it: ``` $ sudo -E bash -c 'echo $xx ~' foo /home/xropi ``` Though many say *~* is not alias, somehow it's part of the environment because *-E* will exp...
Please, consider the following snippet:
$ export xx=foo
$ sudo bash -c 'echo $xx ~'
/root
Which is ok. We can't see xx. However, if I expose it:
$ sudo -E bash -c 'echo $xx ~'
foo /home/xropi
Though many say *~* is not alias, somehow it's part of the environment because *-E* will expose the original preventing me to defer its evaluation. Is it possible to pass my variables and evaluate ~ as /root in the sudo-ed command? I'd like to get this when running with sudo:
foo /root
xropi (93 rep)
Dec 30, 2021, 04:25 AM • Last activity: Dec 31, 2021, 01:40 AM
11 votes
4 answers
7313 views
Create another shortcut `~~` like `~` (home directory)
I want `~~` to point to a different directory so I can use it as a shortcut. I want it to have exactly same functionalities as `~`. How can I do this?
I want ~~ to point to a different directory so I can use it as a shortcut. I want it to have exactly same functionalities as ~. How can I do this?
user121183
Sep 29, 2015, 07:52 PM • Last activity: Jul 14, 2021, 08:48 AM
0 votes
1 answers
69 views
Simple variable assignment: Tilde does not expand in quotes
I have the following expression that is giving an error, but I am unable to figure out the problem. rcutils_path="~/Admir/bin/gungadin-1.0/rcutils" # Re-map modifier keys for dvorak keyboard xmodmap ${rcutils_path}/Xmodmap
I have the following expression that is giving an error, but I am unable to figure out the problem. rcutils_path="~/Admir/bin/gungadin-1.0/rcutils" # Re-map modifier keys for dvorak keyboard xmodmap ${rcutils_path}/Xmodmap
Pietru (403 rep)
Jun 30, 2021, 04:49 AM • Last activity: Jun 30, 2021, 05:05 AM
6 votes
1 answers
7157 views
Command not found in zsh, but found in bash
I'm using `zsh` on ubuntu and I created a symlink for `bat` as so: `ln -s /usr/bin/batcat /home/user_name/.local/bin/bat` hitting `ls -l` from `~/.local/bin` shows: `lrwxrwxrwx 1 tux tux 15 May 19 13:47 bat -> /usr/bin/batcat` Now from any directory(even in `~/.local/bin`), If I run `bat`, I get `co...
I'm using zsh on ubuntu and I created a symlink for bat as so: ln -s /usr/bin/batcat /home/user_name/.local/bin/bat hitting ls -l from ~/.local/bin shows: lrwxrwxrwx 1 tux tux 15 May 19 13:47 bat -> /usr/bin/batcat Now from any directory(even in ~/.local/bin), If I run bat, I get command not found: bat. Also running ~/.local/bin doesn't work. However, running ./bat(from ~/.local/bin) does work. Running batcat also works. echo $PATH shows that ~/.local/bin is in the path What could be going wrong here? no symlink works, bat is just an example P.S. In bash, things are working as expected
Haris Muzaffar (249 rep)
May 19, 2021, 08:32 AM • Last activity: May 20, 2021, 05:44 AM
0 votes
2 answers
2809 views
How to view ~ (tilde) instead of home directory in bash?
I've changed my home directory from `/home/alessandro` to `/mnt/c/Users/aless/Documents/uni/labcalc` (I am using debian in WSL so `/mnt/c` is `C:\` in windows). When I type `cd ~` it correctly goes to my new home directory but in bash the full path is shown and not just `~$`. How can i fix this? UPD...
I've changed my home directory from /home/alessandro to /mnt/c/Users/aless/Documents/uni/labcalc (I am using debian in WSL so /mnt/c is C:\ in windows). When I type cd ~ it correctly goes to my new home directory but in bash the full path is shown and not just ~$. How can i fix this? UPDATE: My $PS1 variable is: \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$
Alessandro Costantini (1 rep)
Dec 16, 2020, 12:04 PM • Last activity: Dec 16, 2020, 07:24 PM
2 votes
0 answers
148 views
Multiple files with the same name and a tilde are written while editing a file with gvim
I am under fedora 29. I edit my files with gvim and since a few days, one of them appears multiple times, renamed with an additional letter and tilde. The directory looks like this : sf1.pdf sf1.tec~ sf1.tef~ sf1.tei~ sf1.tel~ sf1.teo~ sf1.ter~ sf1.teu~ sf1.tex sf1.tez~ sf1.nav sf1.snm sf1.ted~ sf1....
I am under fedora 29. I edit my files with gvim and since a few days, one of them appears multiple times, renamed with an additional letter and tilde. The directory looks like this : sf1.pdf sf1.tec~ sf1.tef~ sf1.tei~ sf1.tel~ sf1.teo~ sf1.ter~ sf1.teu~ sf1.tex sf1.tez~ sf1.nav sf1.snm sf1.ted~ sf1.teg~ sf1.tej~ sf1.tem~ sf1.tep~ sf1.tes~ sf1.tev~ sf1.tex~ sf1.toc sf1.aux sf1.out sf1.teb~ sf1.tee~ sf1.teh~ sf1.tek~ sf1.ten~ sf1.teq~ sf1.tet~ sf1.tew~ sf1.tey~ Apparently the whole alphabet is doing something here, but I really don't udnerstand what's going on (I don't even know what context to provide for more details !). If anyone has a clue as to what's going on and how this could be stopped... Thanks a lot ! Marc
Marc (21 rep)
Mar 30, 2020, 09:30 AM • Last activity: Mar 30, 2020, 03:51 PM
0 votes
4 answers
1786 views
Where is cd ~ located on Ubuntu?
What is the absolute path of ```cd ~``` on Ubuntu? Trying to find out where this ```dir``` is located? For example: /home
What is the absolute path of
~
on Ubuntu? Trying to find out where this
is located? For example: /home
K_G (127 rep)
Mar 26, 2020, 10:15 AM • Last activity: Mar 26, 2020, 12:02 PM
14 votes
1 answers
2359 views
Why tilde (~) doesn't expand when used with CLI argument starting with dash?
I lost a couple of hours trying to run VNC server (x0vncserver) and the client refused to connect with weird message that No password configured for VNC Auth The server also prints this error SVncAuth: opening password file '~/.vnc/passwd' failed Ok, I wasted a lot of time until I realized the tilde...
I lost a couple of hours trying to run VNC server (x0vncserver) and the client refused to connect with weird message that No password configured for VNC Auth The server also prints this error SVncAuth: opening password file '~/.vnc/passwd' failed Ok, I wasted a lot of time until I realized the tilde was neither expanded by the shell, nor by x0vncserver. Then I ran these tests $ echo --PasswordFile=~/.vnc/passwd --PasswordFile=~/.vnc/passwd But $ echo PasswordFile=~/.vnc/passwd PasswordFile=/home/tichomir/.vnc/passwd Why is that? Why the shell refuses to expand tilde if the argument begins with a dash? I thought tilde will always expand as long as it is not quoted, but apparently there is another rule that comes into play?
Tihomir Mitkov (393 rep)
Feb 3, 2019, 10:04 AM • Last activity: Feb 3, 2019, 05:33 PM
3 votes
2 answers
6173 views
Why do you have to put ~/ before .bashrc when opening the .bashrc file?
I'm wondering why it is required to put ~/ before .bashrc when opening the bashrc file. To illustrate: I normally open files on my system as follows: vim filename.extension But while in the /home directory if I do the following: vim .bashrc vim will open a new file called .bashrc In order to open my...
I'm wondering why it is required to put ~/ before .bashrc when opening the bashrc file. To illustrate: I normally open files on my system as follows: vim filename.extension But while in the /home directory if I do the following: vim .bashrc vim will open a new file called .bashrc In order to open my bashrc file I must do as follows: vim ~/.bashrc Why? My current system is Linux Mint 18.3
MarkMark (593 rep)
Jun 13, 2018, 09:47 AM • Last activity: Dec 19, 2018, 11:55 PM
Showing page 1 of 20 total questions