Shell command to print full path to current home directory
Hello,
This is a bit of an odd question. Most commends like echo $HOME will just print /home/user_name . I have a system where /home is mounted in a directory that is not under / and is also not its own partition.
There is a partition that is mounted in fstab with,
The home directory is mounted using a bind mount,
If I click on the home directory icon in dolphin, the location bar indicates /home/user_name as I would expect. Under the hood, this directory should actually be the directory /mnt/linux_data/01_centos/user_name which does exist in that location. I can navigate to /mnt/linux_data/01_centos/user_name by going through the /root icon in dolphin but I would like some means to print the full path to what the OS believes to be /home .
I am having some issues getting dolphin to display the rest of the partition that /home is mounted on and I would like to start by confirming that /home is where I think that it is. Am I making any sense at all???
Do the commands realpath or readlink (with or without -f) help here at all?
Or perhaps the Cwd module from perl:
I have tried the following where dpi.txt is a file in /home/user_name
All of these result in /home/user_name/dpi.txt
The perl code output looked a bit odd be seemed to print the same thing. The readlink command gave the same results a realpath.
It looks like findmnt may give me what I need. Skipping allot of stuff,
This seems to indicate that /home is located on /dev/sdb3/01_centos , which is /mnt/linux_data/01_centos which is expected.
LMHmedchem
Last edited by LMHmedchem; 03-03-2020 at 01:28 AM..
It does not make sense to me.
The purpose of the bind mount is to let it appear under /home/ - why do you want to break it?
I was just trying to confirm that /home was actually mounted at the partition/directory I specified in fstab. I have more than one copy of /home and I wanted to make sure that the version I was looking at in dolphin through the home icon was at the location I was expecting.
As I understand it, when the OS can't find /home where you have specified, the OS will create a /home under / . If you then specify a new /home in a different location (partition etc), the original /home under / will still exist but not be accessible. I wasn't sure how to tell which /home I was looking at. Later, I was curious as to why I couldn't find a simple way find that information and decided to post a question.
I have another related issue I am trying to resolve. I will make another thread about that this afternoon but I first wanted to confirm that my fstab entries were mounting /home where I wanted it.
So basically you want to confirm that /home is on the /mnt/linux_data partition rather than /? You could check out the stat command:
This will give the device number of the partition you are on in decimal. By comparing it with, say, the device number of / you know whether it is on the root or a different partition. Unfortunately stat doesn't give access to the UUID of the device (that I could see, anyway).
While this doesn't in itself confirm that the home directory is mounted on the correct partition, once you have the correct device number you could write a script with that id preloaded into the script.
Of course, all this will have to be done with a script or on the command line, and not, as you initially wished, in the file manager (Dolphin).
Hi
I have a requirement like this:
/abc/a/x.txt
/abc/a/y.txt
/abc/b/x.gz
/abc/b/y.txt
I need output like this:
/abc/a:*.txt
/abc/b:*.txt
/abc/b:*.gz
I have tried find /abc -type f -name "*.*" ||awk -F . '{print $NF}' it is print only extensions without path name.
Please... (5 Replies)
My input is as below :
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt
/splunk/scrubbed/triumph/ifind.triumph.txt
From the above input I want to extract the file names only .
Basically I want to... (5 Replies)
I'm running AIX unix korn shell. If I echo $0, I only get the filename, it does not have the directory name also. So when I do: `dirname $0` it returns a . (meaning current directory). How get $0 to return the full path/filename? Do I need something in my .profile? Thank you. (8 Replies)
Hey
I'm new to the forums here, and I'm seeking help for this script that I'm writing. When I do ls -l of a directory it shows the full pathname for files in it. For example, if the directory is /internet/post/forum/ and the file is topic, it currently shows internet/post/forum/topic. What's the... (3 Replies)
Hi,
Is there a command that tells you right away the current working directory? I know the command "pwd", but that one gives the full path.
if pwd gives me:
/a/b/c/d/ggg/HERE
I want something that will give me:
HERE
Thanks,
Gaurab (13 Replies)
Hi,
I have a file abcd.txt which has contents in the form of full path file names i.e.
$home> vi abcd.txt
/a/b/c/r1.txt
/q/w/e/r2.txt
/z/x/c/r3.txt
Now I want to retrieve only the directory path name for each row
i.e
/a/b/c/
/q/w/e/
How to get the same through shell script?... (7 Replies)
I have a text file with full list of files with their full path. I wanted to sort it by directory then files then subdirectory by alphabetically. When I used the sort command it doesn't give like what I want. Could somebody help me on this.
Here is the ex:
This is what I'm getting... (2 Replies)
Hi guys
I'm trying to move an empty directory to the $TRASH directory. Say the directory i have is ./hello/hello1/hello2 and i'm in hello2, and i want hello2 moved.
this code:
TRASH=$home/deleted
find "$TRASH/$1" -type d -exec rmdir { } \; 2>/dev/null
mv -f $1 $TRASH 2>/dev/null
works... (2 Replies)
Is it unsafe to put your own home directory (a regular user) in your search path? I am writing useful shell scripts, but don't have the permissions to put them in /usr/bin. (Korn shell)
thanks (2 Replies)