date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,412,280,364,000 |
Can administrators know what commands I execute non-interactively through SSH?
For example: does echo hello get logged somewhere at remote if I run this?
$ ssh me@remote "echo hello"
Can remote commands be otherwise monitored?
|
The administrator could install a modified sshd that records everything from all ssh sessions, interactive or not.
The question is: Do you trust the administrator of the remote system?
| Are commands executed through SSH transparent to a remote host's administrator? |
1,412,280,364,000 |
I am running Ubuntu 10.04 LTS. I want to use my laptop to play music in a party. MY screensaver does not need a password to deactivate. I would like to allow people to use my computer to play the music they like, but I would like to prevent them to have access to certain directories in the same manner or similar that ... |
The simplest way I can think of is simply creating a new user partyuser, and assigning it read permissions to a 'public' music directory. To make the music directory (with it's subdirectories and files) to become readable by others you run:
# chmod -R r+o /path/to/music_dir
That way this user can not list or access f... | How to make a folder request root password to view execute? |
1,412,280,364,000 |
I got a VPS with a user dedicated to store my files.
As i am aware of the current situation with the NSA and many other governments, and my VPS is hosted on a doubtful country i would like to ensure my privacy (not that i have any top-secret file, or anything similar).
I am thinking of making the home folder of my use... |
So, since you seem Ok with the idea, for any searchers:
Ecryptfs and its associated PAM facilities do more or less what you want. The filesystem stores an encrypted key which the PAM module locks and unlocks as appropriate. This key is used to read and write files on a fuse filesystem that is mounted on top of the rea... | Mount home partition on user login |
1,412,280,364,000 |
I've I have some scans of sensitive documents in image format such as jpg png etc. When I open up the folder containing them which is in a truecrypt file, will nautilus create a temporary version of the scan or even a thumbnail of the scan on the computer which the file was opened on?
|
TrueCrypt won't, but I don't know about Nautilus. If you want to make sure, check all the files that have been modified during your session:
find /tmp /var/tmp ~/ -type f -mmin 42
where 42 is the number of minutes you've been logged in (the last command might help if you didn't check the time). You can search for ima... | Does truecrypt leave behind temporary files |
1,412,280,364,000 |
There has recently been a (publicly unconfirmed) report that Skype is accessing files that it shouldn't be, without user intervention. I have no idea if this is the case with Skype on linux, but it would be good to be able to find out. Is there a way to keep track of all files accessed by a specific process?
|
Launch your process through strace:
strace -fe open skype
You will see the list of each open() syscall, that is every file (or connection) the processes opens during its life.
Looking at currently opened file descriptors will not provide a log but only a "snapshot" of what the process accesses right now.
| Keep track of all files accessed by a specific process? |
1,412,280,364,000 |
I have a pure-ftpd log file I would like to anonymize periodically. How would I go about doing this? I would like to strip IPv4 and IPv6 addresses. I'm afraid I do not know sed / awk.
The log file looks like this:
Oct 3 19:30:39 hostname pure-ftpd: ([email protected]) [INFO] New connection from 0.0.0.0
I would like ... |
Try this for IPv4:
sed 's/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/HELLO!/g' file
Replace HELLO! with what you need.
Example:
echo "Oct 3 19:30:39 hostname pure-ftpd: ([email protected]) [INFO] New connection from 0.0.0.0" | sed 's/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/HELLO!/g'
Outp... | How to redact all IP addresses from a log file in Debian? |
1,412,280,364,000 |
What are the key differences between "SSH tunnels" and "Squid reverse IPs" in regards to web page scraping and private browsing?
Interested to know if there are any differences between using "SSH tunnels" and "Squid reverse IPs" and how they connect to a website.
For example: do they leave the same HTTP headers and J... |
Private browsing is a complicated thing.
A SSH tunnel can protect you from some kind of sniffing and "man-in-the-middle" attack inside your network, or other LAN focused attack. It will basically connect you to a host, and encrypt the connection between you and this hosts using ssh and add this one to the "path" befor... | What are the key differences between "SSH tunnels" and "Squid reverse IPs" in regards to web page scraping and private browsing? |
1,412,280,364,000 |
How does Whonix Linux keep a user secure?
I am aware of how it works in terms of the Gateway which uses Tor, but how does the Whonix workstation ensure nothing is logged, or stored, on the OS and no fingerprinting can be done on the user who was using the workstation session?
|
how does the Whonix workstation ensure nothing is logged, or stored, on the OS
It doesn't. Whonix is not amnesic.; There is no Whonix Live version yet.; There is no substitute for Whonix's lack of an Amnesic feature
and no fingerprinting can be done on the user who was using the workstation session?
See also docu... | How Does Whonix Keep The User Anonymous? |
1,412,280,364,000 |
An issue was recently opened on the GitHub page for the privacy-focused VirtualBox wrapper HiddenVM. The opener posts what he claims to be indication of files from his local cache being sent to an external IP:
When i used dmesg i saw what it did in the background. I picked two
messages out of many:
audit: type=1400 a... |
The problem description in the GitHub issue was:
The following is how i noticed. It gave me the following error when i tried to start my virtual system: The VirtualBox Linux kernel driver is either not loaded or not set up correctly. Please try setting it up again by executing
'/sbin/vboxconfig'
as root.
Which i did,... | Does this dmesg log show files being transferred? |
1,412,280,364,000 |
I've downloaded a video via a website that forces a login. Thus, it knows my login.
If I run the following on it, I get results that I do not want to have:
strings video.mp4 | grep "my user name"
It always shows up in the video, regardless of the username used. That is, if I download video1 with user1 and video2 wit... |
In the general case, this could be difficult to do. But you are looking at a video. The simplest solution here would be that they placed it into a tag.
The first thing I'd do is examine the tags. If you have it, run mediainfo on the file. Do you see your username in the output? If so, it's just in a tag. You cou... | How to remove data that shows up from 'strings' on a file? |
1,412,280,364,000 |
I remember somewhere mentioned that posting dmidecode output publicly is risky (security/privacy).
|
dmidecode contain private information:
Serial Number
IPMI support
but this information does not make your system vulnerable.
| What are the cons of posting dmidecode output publicly? |
1,412,280,364,000 |
I am an Ubuntu user. I plan to stop using Ubuntu according to Richard Stallman's and privacytools.io recommendations.
I am not very enthusiastic about using Debian because of UX/design which I don't like.
I am curious about how my data are processed.
For my privacy: Is it safe to use ParrotOS (not ParrotSec),
which i... |
The recommendations of https://privacytools.io are Debian, Qubes, and Fedora. I should note you can change the UX/design of Debian (and Fedora, since they both default to the same GUI) by changing from GNOME to a different Desktop, of which there are many. For example, Qubes defaults to the KDE Desktop.
Stallman reco... | Privacy: are elementaryOS and ParrotOS equals to Debian? |
1,412,280,364,000 |
I need to run a script as a regular user on a remote machine whose root I do not trust. This script outputs very sensitive data to stdout.
What steps can I take to ensure only I can read the script’s output?
What steps can I take to ensure remnant files on the disk (if there are any) are permanently destroyed?
|
Root has all privileges on the machine, so there's no way you can protect stdout from root.
If the data had only to transit through the machine (e.g. via a network interface) a solution would be to encrypt it at the source, but since the data is generated on the same machine the root user can easily modify the script... | Privacy as regular user against root? |
1,418,382,232,000 |
I encountered BASEDIR=$(pwd) in a script.
Are there any advantages or disadvantages over using BASEDIR="$PWD", other than maybe, that $PWD could be overwritten?
|
If bash encounters $(pwd) it will execute the command pwd and replace $(pwd) with this command's output. $PWDis a variable that is almost always set. pwd is a builtin shell command since a long time.
So $PWD will fail if this variable is not set and $(pwd) will fail if you are using a shell that does not support the ... | Is it better to use $(pwd) or $PWD? |
1,418,382,232,000 |
pwd gives me
/data/users/me/some/random/folder
Is there an easy way of obtaining
~/some/random/folder
from pwd?
|
If your're using bash, then the dirs builtin has the desired behavior:
dirs +0
~/some/random/folder
(Note +0, not -0.)
With zsh:
dirs
~/some/random/folder
To be exactly, we first need to clear the directory stack, else dirs would print all contents:
dirs -c; dirs
Or with zsh's print builtin:
print -rD $PWD
or
prin... | Make pwd result in terms of "~"? |
1,418,382,232,000 |
Suppose I have a folder:
cd /home/cpm135/public_html
and make a symbolic link
ln -s /var/lib/class .
Later, I'm in that directory:
cd /home/cpm135/public_html/class
The pwd is going to tell me I'm in /home/cpm135/public_html/class
Is there any way to know that I'm "really" in /var/lib/class ? Thanks
|
Depending on how your pwd command is configured, it may default to showing the logical working directory (output by pwd -L) which would show the symlink location, or the physical working directory (output by pwd -P) which ignores the symlink and shows the "real" directory.
For complete information you can do
file "$(p... | How to tell if I'm actually in a symlink location from command line? |
1,418,382,232,000 |
Say I log into a shell on a unix system and begin tapping away commands. I initially begin in my user's home directory ~. I might from there cd down to the directory Documents.
The command to change working directory here is very simple intuitively to understand: the parent node has a list of child nodes that it can ... |
The other answers are oversimplifications, each presenting only parts of the story, and are wrong on a couple of points.
There are two ways in which the working directory is tracked:
For every process, in the kernel-space data structure that represents that process, the kernel stores two vnode references to the vnode... | How does Unix keep track of a user's working directory when navigating the file system? |
1,418,382,232,000 |
In a system with Ubuntu 14.04 and bash, I have the PS1 variable ending with the following contents:
\u@\h:\w\$
so that the prompt appears as
user@machinename:/home/mydirectory$
Sometimes, however, the current directory has a long name, or it is inside directories with long names, so that the prompt looks like
user@m... |
First of all, you might simply want to change the \w with \W. That way, only the name of the current directory is printed and not its entire path:
terdon@oregano:/home/mydirectory1/second_directory_with_a_too_long_name/my_actual_directory_with_another_long_name $ PS1="\u@\h:\W \$ "
terdon@oregano:my_actual_directory_w... | Compact bash prompt when using a directory tree / filename |
1,418,382,232,000 |
I added a symlink to the current directory with ln -s . aa. If I execute cd aa, and after that I executed pwd, the response is /home/sim/aa.
But if I execute /bin/pwd it prints /home/sim (the current directory hasn't changed).
Where does this difference come from?
|
In most shells including bash, pwd is a shell builtin:
$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
If you use /bin/pwd, you must use the -L option to get the same result as builtin pwd:
$ ln -s . test
$ cd test && pwd
/home/cuonglm/test
$ /bin/pwd
/home/cuonglm
$ /bin/pwd -L
/home/cuonglm/test
By default, /... | Strange difference between pwd and /bin/pwd |
1,418,382,232,000 |
I'm doing my first ever moving of user files from an old system to a new system. My goal is to use SCP for it's simple syntax of scp -r source destination. I tried the following command to copy the files first:
scp -r [email protected]:/home/someuser/* .
In retrospect, and from past experience, this copied all files ... |
It's not the . that goes up a level, but the fact that in the shells' pattern match syntax, * means any number of any characters, so it matches the .. entry that exists in every directory and points to the next upper directory. You can get the same with something like ls .* in Bash and many other shells.
Having .* mat... | Why did 'scp 10.0.0.11:/home/someuser/.*' start copying from /home as well? |
1,418,382,232,000 |
I have two shells open. The first is in directory A. In the second, I remove directory A, and then recreate it. When I go back to the first shell, and type ls, the output is:
ls: cannot open directory .: Stale file handle
Why? I thought the first shell (the one that remained open inside a non-existent directory) woul... |
A directory (like any file) is not defined by its name. Think of the name as the directory's address. When you move the directory, it's still the same directory, just like if you move to a different house, you're still the same person. If you remove a directory and create a new one by the same name, it's a new directo... | `ls` error when directory is deleted |
1,418,382,232,000 |
When I display the manual for pwd command, it says that long options like --physical are supported
$ man pwd
PWD(1) User Commands PWD(1)
NAME
pwd - print name of current/working directory
SYNOPSIS
pwd [OPTION]...
DESCRIPTION
Print the full file... |
bash has a built-in command pwd which is what you are using when you simply type pwd into your shell.
To get the pwd as described by the manpage, you need force use of the external command. You can do this by specifying the full path to the executable (/bin/pwd in your case) or by prepending env before the line: env p... | Why pwd does not accept long options like --physical? |
1,418,382,232,000 |
I was wondering if it is possible to keep a file containing history per current working directory. So for example if I was working in /user/temp/1/ and typed a few commands, these commands would be saved in /user/temp/1/.his or something. I am using bash.
|
IMPORTANT: As pointed out by Gilles 'SO- stop being evil'. The approach below can expose your shell to attacks and leak information unintendedly. Proceed with care.
Building off the answer provided by Groggle, you can create an alternative cd (ch) in your ~/.bash_profile like.
function ch () {
cd "$@"
export ... | Create history log per working directory in bash |
1,418,382,232,000 |
I know that pwd gives the current working directory, hostname gives the current host and whoami gives the current user. Is there a single unix command that will give me the output of
whoami@hostname:pwd
so that I can quickly paste the output into an scp command?
|
Not a single command as far as I know, but this does what you need:
echo "$(whoami)@$(hostname):$PWD"
You could make that into an alias by adding this line to your shell's rc file (~/.bashrc, or ~/.zshrc or whatever you use):
alias foo='echo "$(whoami)@$(hostname):$PWD"'
| A command that gives username@hostname:pwd |
1,418,382,232,000 |
In the first terminal A, I create a directory, enter the directory, and create a file:
$ mkdir test
$ cd test
$ touch file1.txt
$ ls
file1.txt
Then in another terminal B, I delete the directory:
$ rm -r test
$ mkdir test
$ cd test
$ touch file2.txt
And back again the terminal A (not doing any cd), I try to list the ... |
How comes that ls doesn't see the problem?
There is no "problem" in the first place.
something is not right in the terminal A
There is nothing not right. There are defined semantics for processes having unlinked directories open just as there are defined semantics for processes having unlinked files open. Both a... | What happens when the current directory is deleted? |
1,418,382,232,000 |
What is the difference between cwd and pwd?
I've tried googling it, and one of the answers mentioned that depending on some factor (which I sadly do not remember), the implementation (the code I'm assuming) is not the same? I don't suppose this is like the difference between print('x') vs return str(x) (to use a Pytho... |
cwd: current working directory (a concept, state, or value)
pwd: print working directory (a command)
Part of the confusion may be that in some shells $PWD is actually the current working directory name, and pwd is a command to display it (similar to echo "$PWD" where available). At the library level, pwd can be impl... | What is the difference between cwd and pwd? |
1,418,382,232,000 |
I'm new to unix. I typed this command in ubuntu terminal:
pwd | echo
I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test)
but the output was just a single empty line.
why this happens?
|
echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.
If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:
$... | why piping pwd and echo does not work? [duplicate] |
1,418,382,232,000 |
When I change directory to //, it seems to put me in a special directory that is very similar to but slightly different to /. However, trying to add any further slashes (///) simply drops me in /.
$ cd / ;pwd
/
$ cd // ;pwd
//
$ cd /// ;pwd
/
$ cd //// ;pwd
/
It seems that // is somehow special, even though it... |
// is a special case, covered in the POSIX definition of the word "Pathname":
Multiple successive <slash> characters are considered to be the same as one <slash>, except for the case of exactly two leading <slash> characters.
On most systems // is the same as /, but it is allowed to be different according to POSIX.
... | Why can I cd to // but not /// or //// or ///// or … [duplicate] |
1,418,382,232,000 |
Question
How do I find out the default directory of a window in GNU screen?
NB: I’m not looking for the current directory of the process running in the window.
Background
I have created a hardcopy of my scrollback buffer without giving an absolute path. Now I don’t know where to find the created file. I don’t remeber ... |
The easiest is probably to just make a new window, it will start in the directory where screen was started by default.
Alternatives include looking at the process' cwd (e.g. /proc/<pid>/cwd, but this requires root as screen is setuid)
Note that you can change that directory with C-a :chdir <path> later
| How to Find out a GNU Screen Window’s Default Directory? |
1,418,382,232,000 |
It seems that I cannot use ./ in qsub as in
qsub -q hpc-pool ./myScript.sh
where myScript.sh contains several ./.
After checking, ./ somewhat is translated to ~/. Why is this the case?
|
Batch jobs submitted by qsub are executed in your home directory by default.
Some versions of qsub support the -d option to specify a different directory. To execute the script in the same directory where you ran qsub, use
qsub -d "$PWD" -q hpc-pool ./myScript.sh
If the -d option is not available, you can access the ... | Current directory ./ in qsub? |
1,418,382,232,000 |
Suppose I have created two folders in /tmp called parent and child. child contains a file called test-child.txt and parent contains a file called test-parent.txt. Now let's go inside the parent and create a symbolic link to the child. Next, go inside the child and try to copy the test-parent.txt from the parent. The b... |
Shells keep track of symbolic links as a convenience for users. This has the nice effect that cd foo && cd .. always goes back to the original directory, even when foo is a symbolic link to a directory. It has two kinds of downsides: the main one is that other programs don't behave this way; additionally, symbolic dir... | copy files from the parent location when I am inside a symbolically linked folder |
1,418,382,232,000 |
i am trying to change dir when from A path to B path like below
pwd|awk '{if($1=="/") cd /tmp/}'
awk: syntax error near line 1
awk: illegal statement near line 1
please suggest
|
Calling cd from within awk is possible (using system(), there is no awk command that is called cd), but wouldn't do much. In particular, it would not change the current working directory of the shell that started awk. The working directory is local to an environment, and awk and any other process or subshell are runn... | how to run shell command inside awk |
1,418,382,232,000 |
How I can get PID number and folder where it works?
If I run 2 same programs in different folders:
/var/www/public_html/first_folder/test.jar <i>(it runs all the time)</i>
/var/www/public_html/second_folder/test.jar <i>(it runs all the time)</i>
If I run this command ps aux | grep test.jar
Result:
www-data 3766 0.5... |
pgrep -x program_name_pattern | xargs pwdx
Explanation
pgrep pattern - looks through the currently running processes and lists the process IDs which match the pattern.
-x, --exact - Only match processes whose names exactly match the pattern.
pwdx - report current working directory of a process.
Testing
pgre... | How to get pid number and folder where it works |
1,418,382,232,000 |
I want to assign the path and file name to a variable:
/path/to/myfile/file.txt
For example
MYFILE=$(pwd)$(basename)
How can i do it ?
|
To answer the question as it is stated: This is a simple string concatenation.
somedirpath='/some/path' # for example $PWD or $(pwd)
somefilepath='/the/path/to/file.txt'
newfilepath="$somedirpath"/"$( basename "$somefilepath" )"
You most likely would want to include a / between the two path elements when concatenat... | Concatenate pwd and basename [closed] |
1,418,382,232,000 |
Obviously I know about pwd and readlink, but is there a command to find out the real absolute path to the current directory (ie, resolving links and dots)?
|
pwd -P
(in any POSIX shell), is the command you're looking for.
-P is for physical (as opposed to logical (-L, the default) where pwd mostly dumps the content of $PWD (which the shell maintains based on the arguments you give to cd or pushd)).
$ ln -s . /tmp/here
$ cd /tmp/here/here
$ cd ../here/here
$ pwd
/tmp/here/... | Real current directory [duplicate] |
1,418,382,232,000 |
The short question is: I need to launch an interactive bash in a certain directory, and I can craft the command that launches bash, but I can't modify the system. At the moment, the command that best fits my needs is
bash -c 'cd some-directory; bash'
That is, I am calling bash, to use cd within bash, and then creatin... |
Using "exec" to replace the current shell is a slight improvement, i.e.
bash -c 'cd somedirectory && exec bash -i'
You could put something like
if [ -n "$STARTDIR" ] ; then
cd "$STARTDIR"
unset STARTDIR
fi
in your ~/.bashrc, and then use
STARTDIR="/some/directory" bash
You could put this in a diffe... | Interactive bash shell: Set working directory via commandline options |
1,418,382,232,000 |
On one of our servers, we have a directory with the following path:
"/daten/i/scripts"
When you go to /daten/i, one can see that scripts is a soft link to "/batch".
When I type cd /daten/i/scripts and then pwd, I see /daten/i/scripts.
Is there a way, a command, that I can type in at /daten/i/scripts that shows me tha... |
Yes, pwd has -P (--physical) option to avoid all symlinks.
So do:
pwd -P
or you can use the canonical way, readlink:
readlink -f /path
Check man pwd and man readlink.
| How can I make pwd resolve a soft link? |
1,418,382,232,000 |
I have a shell script that cd's to a specific directory to run a set of python files. Now that I have this committed to source code management(the script and the python files) I am cloning this into a Jenkins work space and want to run the files from there.
The script is currently written to still cd into the local r... |
If I understand correctly, you want your test directory to be located in the same place as the script.
You can get the location of the script (irrespective of your current directory when you ran it) like this:
MYPATH=`dirname \`readlink -e "$0"\``
Then you can do, for example
cd "$MYPATH/test"
Explanation:
$0 is the... | Running commands from root directory of new workspace |
1,418,382,232,000 |
what I want to do is to find all files based on some search query and get parents parent directory (../..) full path.
For example find . -name "__openerp__.py" and then for each file execute something along the lines of (cd ../..; pwd). Then pipe everything to uniq.
|
Assuming none of the file names contain newline characters:
find "$PWD" -name __openerp__.py | awk -F/ -vOFS=/ 'NF-=2' | sort -u
| print parent directories full path of find output |
1,418,382,232,000 |
I wonder how in one command I can switch to another user (in my case it is usually root) and still remain in the same location where I am before the change.
I usually do it this way, unfortunately taking many steps:
user1@m:~/loc1/loc2$ pwd
/home/user1/loc1/loc2
user1@m:~/loc1/loc2$ su -
Password:
root@m:~# cd /hom... |
According the manual, - and -l are the same option.
-l Simulate a full login. The environment is discarded except for HOME, SHELL, PATH, TERM, and USER. HOME and SHELL are modified as above. USER is set to the target login. PATH is set to ``/bin:/usr/bin''. TERM is imported from your current environment. The in... | How to change user and keep current location? |
1,418,382,232,000 |
So there's $PWD, $PATH, $USERNAME and all that. I've been working on my own shell and I've just today introduced environment variables. The way I'm doing it is by creating strings called pwd, path and all so when there's a command to echo, say, $PWD I tell it to print pwd. Is this the same thing bash does? I don't yet... |
A shell can store environment variables in whatever way it wants. It is not really relevant. What is relevant is that the shell should be able to pass the environment to a child process (including printenv) via the execve system call.
| How/where does the shell store environment variables? |
1,418,382,232,000 |
In bash, I can put set -P in my .bashrc, and to use absolute paths. That is, if I change to a directory through a symbolic link, and then use cd .., it takes me to that directory's canonical parent, not the directory containing the symbolic link.
How can I configure zsh to always use absolute paths?
|
From zshoptions(1)
CHASE_LINKS (-w)
Resolve symbolic links to their true values when changing direc-
tory. This also has the effect of CHASE_DOTS, i.e. a `..' path
segment will be treated as referring to the physical parent,
even if the preceding path segment is a symb... | How can I set zsh to use physical paths? |
1,418,382,232,000 |
I want pwd to return /path/to/dir in the format /path/to/dir/ with the "/" at the end. Any ideas as to how I can accomplish this?
|
With bash4.4+, you could redefine pwd as:
pwd() {
local -
set -o pipefail
builtin pwd "$@" | sed '${/\/$/!s|$|/|;}'
}
That is add a / to the last line of the current working directory if it was not there already (like after cd /) and return the original exit status thanks to the pipefail option (turned on for t... | pwd to return current path with "/" at the end |
1,418,382,232,000 |
I tried a little experiment where I created 2 folders Dir1 and Dir2 inside my Desktop directory, such that Dir1 is parent of Dir2.
/home/username/Desktop/Dir1/Dir2
Then, I use cd to set my pwd as /home/username/Desktop/Dir1/Dir2.
Next I used rm -r /home/username/Desktop/Dir1 to remove the Dir1.
Now if I use pwd it s... |
Actually, Dir2 does exist, but the name Dir2 does not. Confused? :) The shell's current directory is still the directory referred by the name Dir2, and this keeps the directory still around. This is analogous to anonymous files. Normally, when a files link count goes to zero, the file is deleted and the inode freed. H... | Why does the pwd doesn't update after directory removal? |
1,418,382,232,000 |
The feh command allows you to view images within a folder recursively:
feh --recursive --auto-zoom
While viewing images, it also allows you to associate custom commands with keys 0-9 on your keyboard. For example, if I wanted the terminal to output the filename of the image I was viewing (to the terminal), I could ma... |
Just do:
feh --recursive --auto-zoom --action 'printf "%%s\n" %F' "$PWD"
That is:
pass the full path of the current working directory to feh (instead of nothing which feh treats the same as .) so it will give you the full path of files within.
use %F, not %f so the quoting is done correctly (your '%f' would choke o... | Get the Absolute Path from feh |
1,418,382,232,000 |
I have this desktop entry:
[Desktop Entry]
Name=dummy
Type=Application
Terminal=false
Icon=/home/xyz/Software/Test/ico.png
Exec= /home/xyz/Software/Test/start
which is supposed to execute file containing:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./Linux/lib
exec ./foo --gc=sgen
I have tried creating symlink, but res... |
The problem is that you're using relative paths in the script: ./Linux/lib, ./foo. These paths are relative to the current directory. The current directory of the process running the script is the current directory of whatever process launched it; it has nothing to do with the location of the script. When you run the ... | *.desktop nor symlink works (just for this one file) - Linux Mint 17.2 Cinnamon |
1,418,382,232,000 |
Goal: Output .txt file with the full directory path, including name, of all .html files except for those with "txt" or "text" in the .html file name.
I found the following line gives me the desired .txt file with the file's full directory path. The only problem is that it gives me ALL of the folder's contents:
ls -d... |
find will output the found names with the path that you give it, so you can start building the command with
find /Users/username/Desktop/WebsiteFiles
or, if that's where you're located currently,
find "$PWD"
Next, we restrict the found names to only names matching *.html:
find "$PWD" -type f -name '*.html'
If you ... | How to find and print specific file paths with exclusions? |
1,418,382,232,000 |
In Linux (CentOS 7.5, kernel 3.10, gcc 7.3), is it possible to change the working directory of a child process created by posix_spawn before it runs a given process image (an executable)? If yes, how? If no, what is the best practice to do it?
|
There is no way to do thisas part of the posix_spawn() set of functions.
There is an ongoing discussion initiated by redhat whether such a feature should be added. If this gets accepted, it could become part of POSIX in the next version - this may be in 2-3 years.
BTW: posix_spawn() is implemented on top of vfork()/ex... | How to change working directory of a child process by posix_spawn? [closed] |
1,418,382,232,000 |
As far as I know, a process cannot modify its parent's environment. However, when I run mc (GNU's Midnight Commander, a curses-based file manager) and then quit it, I end up with another $PWD:
[localhost ~]$ echo $PWD
/home/pedro
[localhost ~]$ mc
removed `/tmp/mc-pedro/mc.pwd.5616'
[localhost pedro]$ echo $PWD
/nfs/... |
Since the mc command is aliased to . /some/script the script is executed in the current environment (. is equivalent to source in some shells).
A script that is executed in this way may well change the environment of the calling shell, since it's executing in the same environment.
| If processes can't modify their parent's environment, what is MC doing? |
1,464,319,673,000 |
I have a shell script that failed to finish last week; it was a failed "cd" command and it exits if it fails.
The script is a bash shell script for configuring new Debian installs.
Here is the full script: debianConfigAswome.sh. The script is run as root so it has full access to the file-system.
Can you please list al... |
There are various reasons why a cd could fail. The target might not exist, the target might not be a directory, you might not have permission to access the target directory, cd might not be found (although this is extremely unlikely since it's a shell builtin), the chdir() operation might fail due to a broken file sys... | When can a "cd" command fail in a shell script and what can I do to remedy it? |
1,464,319,673,000 |
I have a file that contains paths - looks like this:
/Users/a/Desktop
/Users/a/Documents
/Users/a/Documents/Work
What would be the easiest way to remove all lines that contain the current directory ($PWD)?
|
grep -v "^$PWD$" FILE-LIST
-v inverses the search, so only non-matching lines are printed
^...$ ensures that the pattern only matches the whole line (otherwise all subdirectories of $PWD would got filtered as well)
| Remove all lines that contain $PWD |
1,464,319,673,000 |
Having some trouble getting $PWD to work inside a bash script...
I have two scripts in the same directory:
~/outer.sh, ~/inner.sh. I use outer.sh to call inner.sh as follows:
(outer.sh contents shown below)
#!/bin/bash
$PWD/inner.sh
But this seems not to work. Further investigation shows that $PWD appears inaccess... |
$PWD is the current directory, not the directory containing the script. There's no reason why inner.sh would be located in the current directory.
The path to the script is stored in $0. You can extract its directory part to find the directory containing the script.
script_directory=$(dirname -- "$0")
"$script_director... | calling $PWD from another script |
1,464,319,673,000 |
Display recursively all parent directories relative to the current one.
#!/bin/bash
IFS=/
for var in $(pwd)
do
echo "$var"
done
|
You could do something like:
(
while
[ "$PWD" != / ] && cd -P ..
do
pwd
done
)
There exists however at least one pathological case where that code could run in an infinite loop: when the current directory has been deleted. In that case, I find that on GNU/Linux and with bash-5.0 at least, when bash it n... | Display recursively all parent directories relative to the current one |
1,464,319,673,000 |
I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g.
> cd ~/a/b/c/d
> pwd
> /home/alice/a/b/c/d
Then run the proposed icd command (for "interactive cd", inspired by
imv in renameutils). It prompts the u... |
For bash and any other shell supporting readline you might be able to use this function
icd() { local a; read -ei "${1:-$PWD}" -p "$FUNCNAME> " a && cd "$a"; }
Usage
icd # Starts editing with $PWD
icd /root # Starts editing with /root
| sh: is there a command to interactively edit the PWD? |
1,464,319,673,000 |
Relevant .bashrc section:
if [ "$color_prompt" = yes ]; then
if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] '
... |
Solved by replacing \w and \W in the PS1 with $PWD:
if [ "$color_prompt" = yes ]; then
if [[ ${EUID} == 0 ]] ; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] $PWD \$\[\033[00m\] '
else
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[0... | How to make my PS1 bash session show the whole pwd at all times? |
1,464,319,673,000 |
Actually, I have a folder which contains several sub folders with lots of images in each.
I am trying to gather all the names of the files in each sub folder in a text file (filesNames.txt) in that sub folder in the form of:
Absolute/path/to/each/file/filename
So, I wrote an script in the parent folder:
#!/bin/sh
for... |
Single find command will output all the files with absolute path
find $(pwd) -type f
| find my misunderstanding about this little piece of shell script |
1,464,319,673,000 |
I'm hitting an issue where I need to get the unresolved symlink of a shell process. For example given a symlink ~/link -> ~/actual, if bash is launched with a $PWD of ~/link, I need to fetch that from outside the bash process.
Getting the resolved cwd is possible using lsof or /proc as called out in https://unix.stack... |
The logical value of the current working directory (logical cwd, what you call “unresolved pwd”) is an internal concept of the shell, not a concept of the kernel. The kernel only remembers the fully resolved path (physical cwd). So you won't get the information you want through generic system interfaces. You have to g... | Get the unresolved pwd of a shell from another process |
1,464,319,673,000 |
Trying to do something like (in pseudo-unix):
scp -r <pwd> [email protected]:~/<dirname of toplevel>
In other words, I'm trying to copy the current directory I'm in locally (and the contents) over to remote while sticking the very last path segment from "pwd" commands output onto /home/user/<here> in the remote.
I'm ... |
$ scp -pr "$(pwd)" [email protected]:"$(basename $(pwd) )/"
| Use SCP from local machine to recursively copy current working directory to remote? |
1,464,319,673,000 |
I installed bash on my Windows machine, and now when I run the shell, the pwd is:
/mnt/c/Windows/System32
How may I change this?
I open this shell everyday to work, and the directory when I'm working is:
/mnt/c/Users/[myname]/Desktop/cours/rootMe
So, it would be faster if my pwd when I'm running the shell is the ... |
You could try editing ~/.bashrc for it. (Probably C:\Users\[myname]\.bashrc)
Append the following line:
cd /mnt/c/Users/[myname]/Desktop/cours/rootMe
More details on executing commands on shell startup - here.
| Change path directory bash.exe |
1,464,319,673,000 |
When I work under tcl environment, once I cd to a directory, even if the path I specify is its symbolic link, then no matter whether I run pwd -L or pwd -P, they all return the absolute path. This is troublesome for me because I try to replace a user-specific workspace path with a variable name so that when different... |
Doesn't look like Tcl gives you any control over cd and pwd.
An alternative: resolve the symbolic links in the WORK env var, and compare that to pwd:
format {cd "%s"} [expr {[pwd] eq [file normalize $::env(WORK)] ? {$WORK} : [pwd]}]
| tcl cd/pwd command with regard to real/symbolic path |
1,464,319,673,000 |
I'm trying to set up SFTP's home directory on a MAC OS X Mavericks for user my_user. Now, it looks like:
/Users/my_user (i got it with sftp> pwd command)
but I want it be:
/Users/my_user/Documents/new/dirs
How can I do this?
|
You didn't specify if you want to change actual home directory of user or starting directory of sftp. The first is not a good idea to change, but you can certainly do that using your user settings.
The start directory of your user can be set up in sshd_config, where you define sftp subsystem, like this (path on Mac wi... | How I can change the home directory of the sftp server on MAC OS X? |
1,464,319,673,000 |
To know, what is my CWD in console, I added the following to ~/.bash_profile:
export PS1='$(pwd)$ '
So, pwd result it shown before the $ symbol. It was very nice.
But when I go to a directory with a long name: /var/www/vhosts/beta.sitename.co.uk/httpdocs/sites/beta.sitename.co.uk/modules/bundles
In the command prompt... |
In my .bashrc, my PS1 is configured to display the last component of my current working directory. This can be done using \W (PS1 allows some special sequences along with variables). In your case, that would be:
$ export PS1='\W$'
More of these sequences may be found in man bash, at Prompting, see here. You may also ... | How to trim the CWD, shown in the command promt |
1,464,319,673,000 |
All,
I have a file (called, say, bundled_file.txt) of here docs stored in a directory, and the file looks like this:
cat > a.txt << 'eof'
...
...
...
'eof'
cat > b.txt << 'eof'
...
...
...
'eof'
cat > c.txt << 'eof'
...
...
...
'eof'
I want to un-bundle this file so that the files a.txt, b.txt, and c.txt get created... |
Self-answer ...
Let's say the file bundled_file.txt is in the folder called test ... and let's further say that my pwd is in the directory above, meaning the parent directory of test ...
I found this, which works well even though it's changing the pwd, but it immediately returns to the parent directory:
In bash, somet... | unbundling a file of here docs when file's directory is different from pwd |
1,464,319,673,000 |
I'm looking for a way to do something like this without attaching to the session.
tmux attach-session -c <directory> -t <session>
^^^^^^^^^^^^^^
Per tmux(1), there isn't a way to change the default working directory (new windows and new panes) of an entire session without attaching to it.
I cannot... |
You can simply
tmux attach -c directory -t session 2> /dev/null &
the attaching will exit immediately as the forked background job is not a terminal. But it will succeed in changing the working directory of the tmux session.
Edit: I corrected -s with -t but the trick does not seem to work anymore in tmux 3.1b.
| tmux change default working directory of a session without attaching |
1,464,319,673,000 |
I use this shell pipeline to get a SQL dump using the terminal:
$ cd var/lib/mysql && mysqldump -uroot -p"craft" --add-drop-table craft > ~/../docker-entrypoint-initdb.d/base.sql && cd ~/..
As can be seen, I entered the var/lib/mysql directory and create the dump to a file and come back from where I was initially.
T... |
To be honest, I don't see a reason for the two calls to cd at all.
You don't seem to use the directory that you cd into for anything. You give an absolute path for the location of the database dump. If any custom MySQL configuration file is needed, that would be picked up from the user's home directory in any case.
Y... | How to run a command with a different working directory? |
1,464,319,673,000 |
I have been using *nix systems for a while now, and I was surprised to see this situation in which mv misplaces or deletes my file. For example, I had a file foo.txt in the directory called previousVersions, and when I was in that directory's parent directory, I issued the command
mv previousVersions/foo.txt ..
expe... |
mv previousVersions/foo.txt .. will move the file foo.txt to the directory above your working directory. To have the file be moved to your working directory, replace .. with .:
mv previousVersions/foo.txt .
With the file presently in the parent directory of your current working directory, you can move it to your curre... | mv .. with path: Where does my file go? |
1,464,319,673,000 |
Between the various parameters that can be included in the bash PS1 variable, \w expands
the current working directory, with $HOME abbreviated with a tilde
(uses the value of the PROMPT_DIRTRIM variable)
as stated in the Bash manual.
My $HOME is set to /home/myuser/ (the same value specified in /etc/passwd), but t... |
The trailing / in /home/myuser/ is confusing bash. I think you'll see normal behavior if you remove it.
That slash isn't part of the directory name; it's a path separator. It shouldn't be in /etc/passwd, and it shouldn't be in $HOME.
You can test that theory without touching a file using just:
HOME=/home/myuser... | Parameters in bash $PS1 variable |
1,464,319,673,000 |
I wondered what might be a safe or the Unix compatible way to change to the directory from which a script is called.
These two methods even work in a directory with spaces and special characters in it, without using quotes. But there might be some situations where this might not work. Or is there?
#!/bin/bash
cd $(di... |
Beware that $0 can be a relative path, so calling cd twice might not work. Apart from that, extracting the directory part of $0 works in most cases. Most is not the same as all. Some cases where it can fail include:
The script is not invoked by running its path but by calling a shell on it, e.g. bash myscript (which ... | What is the safest (or most elegant or shortest) way to change to the directory from where a script is called? |
1,464,319,673,000 |
WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file:
alias pwd=" echo "${PWD}/" "
But it doesn't work properly. Instead of printing my present working directory with a trailing slash, it pri... |
Your issue is that the $PWD part of your alias definition is unquoted (you close the double quoted string just before $PWD and then start a new one just afterwards). This means that it is evaluated when the alias is defined.
Instead, use single quotes around the whole alias text, or even better*, use a shell function... | Can I reprogram the pwd command to add a trailing slash? |
1,464,319,673,000 |
I created a directory dir at Desktop and then i keyed in cd dir so as to make dir as my current directory and then i typed in the terminal rmdir /home/user_name/Desktop/dir from the dir directory itself, and surprisingly this removed the dir directory but when i checked my current working directory using pwd it was st... |
If you want to understand why this is, you need to understand the difference between files and inodes. rm, rmdir and mv all take action on the inodes describing the file/directory, not the actual file. If you have a file/dir open (e.g. by being in the directory), the inode information is removed, but the actual data ... | Trying to remove current directory using rmdir |
1,464,319,673,000 |
I have a file which has the following content:
BWA='/software/bwa/bwa-0.7.12/bwa'
SAMTOOLS='/software/samtools/samtools-1.3.1/samtools'
The above tools are on my computer:
which bwa => /work/waterhouse_team/miniconda2/envs/arima/bin/bwa and
pwd/hic-fq => /scratch/waterhouse_team/benth/dbg2olc-40x/hic-fq
Next, I us... |
You can try these commands instead:
sed -ri.bak "s#software/bwa/bwa-0.7.12/bwa#`which bwa`#g" mapping_arima.sh
sed -ri.bak "s#software/samtools/samtools-1.3.1/samtools#`which samtools`#g" mapping_arima.sh
| content from pwd and which failed with sed to be replaced [duplicate] |
1,464,319,673,000 |
startScript.sh is in /root/script/startScript.sh
script1.shis in /root/script/test/script1.sh
script2.sh is in /root/script/test/script2.sh
startScript.sh looks like below
#!/bin/bash
#some code!
sh `pwd`/test/script1.sh 2>&1 &
sh `pwd`/test/script2.sh 2>&1 &
#some code
script2.sh and script1.sh look like below
#!/... |
Why don't you just add test/ to the path of the file you're trying to create, i.e.
#!/bin/bash
> `pwd`/test/process_ids.txt
while true;do
echo "The Process: `ps`" >> `pwd`/test/process_ids.txt
#some code to parse the process, etc. and echo it
done
| How to get `pwd` in the shell script that was started by another shell script [duplicate] |
1,464,319,673,000 |
I am writing pwd in terminal, and it is showing home/<my_username>. But I cannot physically find any directory with this path. To clear my confusion, I typed ls, but it shows the folders in my Home directory that I can see from file manager. But I cannot a folder with <my_username> inside Home. What am I missing here?... |
pwd will output the pathname of the current directory. When you are located in your home folder, pwd will return the pathname of it.
In your case, the pathname of your home folder is /home/proteeti. This is your current working directory. Typing ls whilst located in that folder will show you its contents.
You can no... | Difficulty in undersanding pwd command |
1,464,319,673,000 |
I have a script which before being launched checks via pwd if the path upon launch is something specific (say dir/subdir/script)
current_folder=$(pwd | grep dir/subdir/script)
if [ "$current_folder" == "" ]; then
{
echo "something bad"
exit
}
fi
how can this script be launched via crontab? I cannot remove the check w... |
You can specify several commands, separated by ; or &&, as your
cron job, for example:
* * * * * cd /some/path && foo
(This will only run foo if the cd was successful.)
| launch a script which requires to be launched from a specific path via crontab |
1,464,319,673,000 |
I'm trying to display path in colors but I have problem with this.
I have some constant path - in variable MyPath.
I want to create colorized path in PS1 but if pwd showing different path then my (but including MyPath) then the rest I want to print in different color (with slash in different color).
I wrote some code ... |
I'd put something similar to the followig code in .bashrc without requiring other files to be in open&write each time you press the enter key
SEP=("/" "/")
SEP_COLOR=("\e[0;34m" "\e[0;32m") #colors for: (FIXED - DEFAULT) SEPARATOR STRING
DIR_COLOR=("\e[0;32m" "\e[0;31m") #colors for: (FIXED - DEFAULT) DIR NAME... | colorized path in PS1 |
1,464,319,673,000 |
I'm making some shortcuts to games I would normally run via terminal. For instance,
UT2004:
cd "$HOME/Unreal Tournament 2004/System/"
./ut2004-bin-linux-amd64
My work so far:
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Path=/home/nick/Unreal Tournament 2004/System/
Exec="/home/nick... |
The way I worked this out was to have a start-up script that changes to the correct directory and then starts the game.
startup.sh :
#!/bin/bash
cd /path/to/game
game
cd "OLDPWD"
And then in the .desktop file use :
Exec=/bin/bash /path/to/startup.sh
| GNOME ".desktop" shortcut: Specify Start-In path |
1,464,319,673,000 |
I have the following bit of code in a bash script I've created. When I run it from a directory with no spaces in the path it works as expected, however if I run from a directory with spaces it fails. I'm pretty sure I need to escape it somehow, but nothing I've tried seems to work.
for file in `pwd`/*
do
echo fi... |
Thanks to Paulo Tomé I needed to change it to the following:
for file in "$(pwd)"/*
do
echo file:"$file"
done
| Can't loop files using pwd if current directory has spaces in the path [duplicate] |
1,367,888,728,000 |
I have a software RAID5 array (Linux md) on 4 disks.
I would like to replace one of the disks with a new one, without putting the array in a degraded state, and if possible, online. How would that be possible?
It's important because I don't want to:
take the risk of stressing the other disks so one may crash during r... |
Using mdadm 3.3+
Since mdadm 3.3 (released 2013, Sep 3), if you have a 3.2+ kernel, you can proceed as follows:
# mdadm /dev/md0 --add /dev/sdc1
# mdadm /dev/md0 --replace /dev/sdd1 --with /dev/sdc1
sdd1 is the device you want to replace, sdc1 is the preferred device to do so and must be declared as a spare on your a... | How to safely replace a not-yet-failed disk in a Linux RAID5 array? |
1,367,888,728,000 |
Some time ago I had a RAID5 system at home. One of the 4 disks failed but after removing and putting it back it seemed to be OK so I started a resync. When it finished I realized, to my horror, that 3 out of 4 disks failed. However I don't belive that's possible. There are multiple partitions on the disks each part of... |
First check the disks, try running smart selftest
for i in a b c d; do
smartctl -s on -t long /dev/sd$i
done
It might take a few hours to finish, but check each drive's test status every few minutes, i.e.
smartctl -l selftest /dev/sda
If the status of a disk reports not completed because of read errors, then thi... | How to recover a crashed Linux md RAID5 array? |
1,367,888,728,000 |
I have a healthy RAID5 array with 5 disks:
# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid5 sdb1[6] sdd1[0] sdh1[5] sdf1[2] sde1[1]
31255166976 blocks super 1.2 level 5, 512k chunk, algorithm 2 [5/5] [UUUUU]
bitmap: 0/59 pages [0KB... |
Unmounting (filesystems) is not sufficient.
You'd have to stop the array then re-assemble it afterwards:
mdadm --stop /dev/md0
# re-arrange / hotplug drives
mdadm --stop /dev/md0 # (*)
mdadm --assemble /dev/md0
It makes sense to check journalctl / dmesg, and/or cat /proc/partitions / lsblk, to make sure the drives go... | Can a RAID5 disk be moved to a different slot? |
1,367,888,728,000 |
I have a raid5 array with quite large disks, so reconstruction is really slow in case of a power outage. Thankfully, there is the --write-journal option for linux md raid. The man page lists the --write-journal option in the For create, build, or grow: section, so I supposed it should work in grow mode, and tried to a... |
It kind of should work like this:
# mdadm --manage /dev/md42 --readonly --add-journal /dev/loop3
mdadm: Journal added successfully, making /dev/md42 read-write
mdadm: added /dev/loop3
However, currently (using kernel 4.18, mdadm 4.1-rc) that only seems to be possible for arrays that were created with journal in the f... | Add linux md raid write journal to and existing array |
1,367,888,728,000 |
A friend of mine has a mdadm-raid5 with 9 disks which does not reassemble anymore.
After having a look at the syslog I found that the disk sdi was kicked from the array:
Jul 6 08:43:25 nasty kernel: [ 12.952194] md: bind<sdc>
Jul 6 08:43:25 nasty kernel: [ 12.952577] md: bind<sdd>
Jul 6 08:43:25 nasty kernel: [... |
OK, it looks like we have now access to the raid. At least the first checked files looked good. So here is what we have done:
The raid recovery article on the kernel.org wiki suggests two possible solutions for our problem:
using --assemble --force (also mentioned by derobert)
The article says:
[...] If the event c... | Reassemble mdadm-raid5 |
1,367,888,728,000 |
I currently have 2 3TB HDDs, one that is always almost full, and another with ~200GB free. I would like to purchase an extra 3TB drive and setup a RAID 5 array, but I am concerned about losing the existing data.
I have found that mdadm will be used to create the array, with a command similar to mdadm --create --verbos... |
You have two 3TB disks storing 6TB data. You want to install one new 3TB disk.
This will allow you to convert the three 3TB disks into a RAID5 array storing 6TB data. However, the process is rather fiddly and the opportunities for losing data somewhere along the route are fairly large.
Steps to achieve the requirement... | How to create a 3x3TB RAID 5 array without losing data from 2 of the drives? |
1,367,888,728,000 |
Context
I have a software RAID5 array (mdadm) on 3 disks. Last week, one disk started to get reading issue:
# dmesg
ata3.00: exception Emask 0x0 SAct 0x30000001 SErr 0x0 action 0x0
ata3.00: irq_stat 0x40000008
ata3.00: failed command: READ FPDMA QUEUED
ata3.00: cmd 60/08:e0:40:0b:c6/00:00:a1:00:00/40 tag 28 ncq dma 40... |
Caught between a rock and a hard place. Pick your poison.
You could
leave it running as is and hope for the best,
--fail /dev/sdc1 to kick the offending drive directly,
add another drive and --replace /dev/sdc1, (perhaps this is what you meant to do instead of --grow?)
Or --stop the array and then
--assemble --upda... | RAID5 - Mark a disk faulty during reshape |
1,367,888,728,000 |
I had RAID5 array of three disks with no spares. There was a power out, and on reboot, the array failed to come back up. In fact, the /dev/md127 device disappeared entirely, and was replaced by an incorrect /dev/md0. It was the only array on the machine. I've tried to reassemble it from the three component devices, bu... |
You've got a rather scrambled-looking system there. The key elements from your mdadm --examine output:
/dev/sdc1:
Update Time : Sat Oct 11 09:20:36 2014
Events : 15084
Device Role : Active device 2
/dev/sdd1:
Update Time : Wed Oct 15 08:09:37 2014
Events : 15196
Device Role : Active... | Missing mdadm raid5 array reassembles as raid0 after powerout |
1,367,888,728,000 |
I've got a brand new Ubuntu 20.04 machine built out which is using a mdadm RAID5 configuration (3x 10TB). The system is throwing an error every time I log in. I can see from systemctl that the mdcheck_start service has failed.
I can also see from checking the service status that the daemon is trying to launch a script... |
This appears to be a bug in Ubuntu 20.04's mdadm package. The mdcheck script is missing altogether so the timer/service fails to execute the it.
When you install mdadm, it also activates the mdcheck_start timer and service.
# apt-get install mdadm
[...]
Setting up mdadm (4.1-5ubuntu1) ...
Generating mdadm.conf... done... | mdcheck_start Service Fails to Start |
1,367,888,728,000 |
I have an old PCI-X controller running 8 drives in RAID 5. I'd like to dump the controller and go to software RAID under Ubuntu. Is there a way to do this and retain the data from current array?
EDIT: (and a slight tangent) The answers below are certainly fine, but here's a bit of added detail in my specific situation... |
If you actually have a RAID configured through hardware (i.e., the operating system sees fewer physical disks than you actually have) there's no hardware to software conversion method. You have to back up the data to an alternate location, convert the RAID manually, and restore.
| Migrating from hardware to software RAID |
1,367,888,728,000 |
I have a home server running Centos 7 that I'm using to host various different servers - a webserver, two Minecraft servers, and a PLEX server. Currently I have a 4TB HDD which serves as the primary storage, housing the OS and all files, and a 240GB SATA SSD which I'm using as a cache drive with Lvmcache. I've begun... |
Answered by a combination of the posts linked by Tink and Roaima in this comment
How about this one? At least it directly addresses LVMs as well ... Migrate an entire volume group LVM2 to RAID5
Does this answer your question? How to create a 3x3TB RAID 5 array without losing data from 2 of the drives?
| Migrate Single Disk to RAID [duplicate] |
1,367,888,728,000 |
I have Raid 1
/dev/sda /dev/sdb
as md0
then now I want to expand for Raid5
So, my idea is
sudo mdadm --add /dev/md0 /dev/sdd
sudo mdadm --grow /dev/md0 --level=raid5 --raid-devices=3
In these processes.
The contents in the HDD will be deleted or not??
|
Yes it's perfectly possible, and can be done even on a live system.
IMPORTANT NOTE: your data won't survive a disk failure during the conversion process, so make sure you have a backup.
Here's a demonstration using some files.
# Two "disks", probably called /dev/loop0 ($a) and /dev/loop1 ($b)
dd bs=1M count=100 </dev/... | Is it possible to keep data in procedure Raid1 growing to Raid5? |
1,367,888,728,000 |
At our university we have a Windows FTP server that was implemented with software RAID-5 technology, but we decided to migrate to Linux.
How can we mount and modify it under Linux?
|
In case of a software raid setup on Windows this is probably a fake-raid. You should install the package dmraid which will handle access to such raid-5 systems.
Do make a backup of your data before you start.
You can try out dmraid by booting from CD and installing it, without any need to change the Windows setup.
dm... | How to mount software RAID-5 created by Windows under Linux? |
1,367,888,728,000 |
I have 3 3TB drives, and have raid5ed them together. I would expect to get a resulting device around 6TB. The command I used:
mdadm --create md0 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1
Also of note:
# fdisk -l | grep 'Disk /dev/sd'
Disk /dev/md0 doesn't contain a valid partition table
Disk /dev/mappe... |
How did you partition the disks the first time? If you used fdisk, you may have limited yourself to just the first 2 TB of each disk, as that's the maximum partition size you can create with fdisk. As such, your raid device probably looks more like a RAID5 of 3 * 2TB disks.
Use parted to create your larger than 2TB ... | Raid5 Device Has Less Space Than Expected |
1,367,888,728,000 |
So I'm currently building an mdadm RAID5 array attached to my home server. The hardware is an Odroid N2 SBC with a Mediasonic Probox 4 bay enclosure attached. The array is currently rebuilding and has been for days but moving steadily. I'm using armbian stretch with the legacy 4.9.180 kernel.
Last night, I was usin... |
(Once the current rebuild is finished,) you can run a check:
mdadm --wait /dev/mdX # wait for rebuild to finish
mdadm --action=check /dev/mdX
# or if mdadm is too old:
echo check > /sys/block/mdX/md/sync_action
and then watch the mismatch_cnt:
watch cat /sys/block/mdX/md/mismatch_cnt
as long as it stays 0, the parit... | How to check mdadm RAID5 integrity after power failure/random reboot |
1,367,888,728,000 |
I have a 3 drive raid 5 array using the following disks:
/dev/sda
/dev/sdc
/dev/sdb
I'm no longer able to mount the drive with the following error:
sudo mount /dev/md0 /mnt/md0/
mount: wrong fs type, bad option, bad superblock on /dev/md0,
missing codepage or helper program, or other error
In some cases usef... |
First of all, mount it read-only and make a backup of your data.
Then run e2fsck on /dev/md0, which should be able to fix the filesystem, but the most recent changes to it are probably lost.
| Unable to mount raid 5 array (mdadm), with no drive errors |
1,367,888,728,000 |
I had a 2 disk RAID 1 partition. I added a device and converted it to RAID 5:
mdadm --add /dev/md3 /dev/sdd2
mdadm --grow /dev/md3 --level=5 --raid-devices=3
Then added another device and converted to RAID 6:
mdadm --add /dev/md3 /dev/sde2
mdadm --grow /dev/md3 --level=6 --raid-devices=4
When completed, the capacity... |
All the operations you did were to change the RAID partition structure, but none of those actually resize the filesystem written on it.
This means that the filesystem is not aware of the changes you did and if you ask it about its size, it will give you the size it was created.
To correct that, you can run resize2fs... | ubuntu - raid partition capacity unchanged after RAID1 to RAID5 to RAID6 |
1,367,888,728,000 |
A bit of history to start with. I had a 4 disk RAID5 and one disk failed. I removed it from the array and had it in a degraded state for a while:
mdadm --manage /dev/md127 --fail /dev/sde1 --remove /dev/sde1
My data requirement suddenly dropped so I decided to permanently reduce the array to 3 disks. I shrank the fil... |
Spare should be put into use automatically. It's strange it didn't.
You may try to remove and re-add the spare:
mdadm -f /dev/md127 /dev/sdc1
mdadm -r /dev/md127 /dev/sdc1
mdadm --zero-superblock /dev/sdc1
mdadm -a /dev/md127 /dev/sdc1
If it doesn't work, there should be error messages in dmesg, explaining what's wro... | How do I make a spare device active in a degraded mdadm RAID5 |
1,367,888,728,000 |
I had the following setup:
3 HDDs 10Tb of size, in LVM Raid5 configuration
On top a LUKS2 encryption and inside a BTRFS filesystem.
Since my storage got low i added another 16TB HDD (was cheaper than 10TB) added it as physcial volume in LVM, added it to the volume group, ran a resync, so that LVM can adjust the size o... |
I could not find the root cause of this problem, so I decided to ditch LVM in it's entirety and replace it with mdadm - which worked like charm on the first try.
Creating mdadm RAID5 (initially with 3 disks)
Creating with three disks (henceworth raid-devices = 3):
mdadm --create mediaraid --level=raid5 --raid-device... | LVM, LUKS2 & BTRFS Problem |
1,367,888,728,000 |
This is a long time in the making, and I've finally got it working so I thought I'd share this with as many people as I can in case they're in a similar situation.
Long story short - HP SmartArray P410 failed, got another one (which worked for a while) then also failed. I also had a P200/ZM in there with another array... |
The source tarball is available from: HERE
| HP SmartArray RAID5 recovery on linux |
1,367,888,728,000 |
I stumbled upon this question, but I do not think this is a duplicate since I'm under the impression that the OP in this question is not running under a live session. I, on the other hand, have booted to an Ubuntu live USB drive for this operation.
I have an Ubuntu installation where everything lives on an LVM2, save... |
Basically, everything except for /boot & update initramfs is the same. I'll assume that your old boot is /dev/sda1. These steps should look familiar if you've ever used a live CD/USB as a rescue disk:
# mount /dev/vg0/root /mnt # or whatever your vg/lv name is.
# mount --bind /dev /mnt/dev # make these availab... | How can I migrate my Ubuntu installation from LVM2 to RAID5? |
1,367,888,728,000 |
Had a power outage two weeks ago on my BSD server that my UPS decided then was a good time to fail. Just fired it up this evening only to have the following errors show during what I would assume is the rebuild process.
The port for the ECC error has shown up as either 2 or 1 in following errors, and while the rest o... |
What you should do here is trigger a SMART self-test on the bad drive(s). That will pull a lot of the controller/motherboard pieces out of here and give you a better reading on the underlying disks having issues. It's possible for non-drive failure to give wrong results there--power supply failure is the most common... | Worrisome HD related messages after power outage |
1,367,888,728,000 |
I found simmilar problem here: Missing mdadm raid5 array reassembles as raid0 after powerout, but mine is a bit different.
Here too my raid5 reassembles as raid0, but i don't see any of my devices marked as spare in mdadm -E /dev/sdX1 output:
/dev/sdb1:
Magic : a92b4efc
Version : 1.2
Feature Map... |
Ok, just to conclude this - basically, what was said in that link helped, here are my exact commands:
mdadm --assemble --force /dev/md0 /dev/sdb1 /dev/sdc1
mdadm --add /dev/md0 /dev/sdd1 (--re-add didn't work), after this it started resyncing - took about 20 hours
Then, since there is lvm over:
lvchange -ay data/d... | raid5 array reassembles as raid0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.