date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,479,012,077,000
For past couple of days I have been observing weird processes in one of our server. Most of the time I see multiple instances of executable 10 and sometimes 4 and takes a lot of cpu resources. When examined this I have been seeing the process is started by cron right after starting a process with executable cpu_hu. W...
(Rewritten based on OP's comments) The cpu_hu seems to execute as user postgres, which suggests it might have been started by using a weakness in your PostgreSQL database engine or its configuration. Maybe your PostgreSQL database is accessible from the internet and your database admin password is nonexistent or weak?...
Possible Malware: Unable to track starting point
1,479,012,077,000
I looked around for an antivirus on Linux (Arch) or malware scanner, bumped on ClamAV and I don't even remember if I got it to work so fair to say it didn't make the cut at the moment in time. Are there free, good AVs for Linux? I find people saying there are no viruses for Linux, that's why there are no AVs, but I f...
maldet is the best solution for malware detection on Linux. It's using it's own signature database, and can use ClamAV as an engine. I've used it for many years and it has always detected all kinds of malware on production systems.
Are there decent, free malware solutions for Linux? [closed]
1,479,012,077,000
My external hard disk got a windows virus which makes lots of filename.exe copies of 132.6 kb. When I write find . -type f -name "*.exe" it founds thousands of .exe files and only 100 or 200 of them are my files. Do you know a smart way to extract virus files and delete all at once without losing my data?
Use find with -size option: find . -type f -iname '*.exe' -size 133k or find . -type f -iname '*.exe' -size 135783c after you confirm those are bad files, you can add -delete option to the command to delete those files. from man find: -size n[cwbkMG] File uses n units of space, rounding up. The follow...
How to delete all the "*.exe" files which is 132kb
1,479,012,077,000
I installed elementary OS Juno on an old iMac 5,1. The Computer uses a 32bit EFI, which is not able to boot elementary OS Juno so I decided to follow Matt Gadients guide for a little workaround. You can find the workaround here: https://mattgadient.com/2016/07/11/linux-dvd-images-and-how-to-for-32-bit-efi-macs-late-20...
You could compare the original image to the modified image using, e.g., cmp -l. (Which for true paranoia, you should of course do from a system you didn't run the C program on). That C program appears to just set 1984 bytes to 0: if (lseek(fd, lba * 2048 + 64, SEEK_SET) == -1) goto err_ex; memset(buf, 0, buf_size); ...
Still safe to use distro after applying c program to it?
1,479,012,077,000
I've just spotted in .bash_history file lines below: grep -iHlnr 'filesman' *2> /dev/null grep -iHlnr 'eval.*base64_decode' *2> /dev/null From Google I know that is something like 'malware finding command'. May somebody explain what does it exactly do? (Iknow what is grep for, but that syntax isn't clear to me).
The commands you posted do nothing useful — they run grep on files whose name ends with 2, and recursively in directories whose name ends with 2. There's a missing space after * (the space after > is permitted but not useful and more confusing than anything): grep -iHlnr 'filesman' * 2>/dev/null grep -iHlnr 'eval.*bas...
Explain Malware-finding function in bash
1,479,012,077,000
I am web hosting websites on Apache/2.2.22 and did a security scan. The scan said the server software is outdated; the web hosting provider says its not outdated and is stable. Someone uploaded malware to non-www directories. Could the malware have happened due to the outdated Apache/2.2.22 software? This is a share...
Could the malware have happened due to the outdated Apache/2.2.22 software? Possibly. There are a number of vulnerabilities against version 2.2.22 which are listed here: http://www.cvedetails.com/vulnerability-list/vendor_id-45/product_id-66/version_id-142323/Apache-Http-Server-2.2.22.html As well as here on Apache'...
Hosting on Apache/2.2.22, scan says outdated
1,479,012,077,000
I am interested to know whether is it a reasonable decision to try and restrict my own user account as much as possible to the point where I would need to use my own password much more frequently (now I use it only for mounting new disks and for system updates). For example I downloaded and opened a malicious program ...
Would this program be allowed for example: take a whole screenshot of my desktop Under X11/X.org, yes, easily. Under Wayland it's complicated but possible. sniff my keystrokes (for later use for sudo as an example) Likewise. listen or watch my microphone or webcam Yes. and adding itself in autostart (systemd se...
What is the worst thing a usermode (ring3) virus could do to home linux installation?
1,479,012,077,000
I am running MalDet (malware detection) and ClamAV (anti-virus) on my RedHat 7.x server and wish to run these processes simultaneously. Other than using CPU resources, can running these two processes at the same time have a negative effect (most importantly, can one effect the other negatively)? I don't think they wil...
The short answer would be 'no'. In fact, after linking both ClamAV and Maldet together, when you run a Maldet scan, it will also include the definitions of ClamAV and will actually improve performance for your MalDet scans.
Will running MalDet (malware detection) and ClamAV (anti-virus) at the same time cause any issues with the operation of each other?
1,479,012,077,000
using strace I have found a behaviour of ldconfig (glibc), I can make no sense of lstat("/usr/lib/libext2fs.so.2", {st_mode=S_IFLNK|0777, st_size=16, ...}) = 0 unlink("/usr/lib/libext2fs.so.2") = 0 symlink("libselinux.so.1", "/usr/lib/libext2fs.so.2") = 0 Is there any need to have the shared object library for ...
Your library was probably renamed by mistake at some time from /usr/lib/libselinux.1 to /usr/lib/libext2fs.so.2 . This doesn't prevent ldconfig to find the expected name from the library's content (rather than the library's file name) and thus link the "correct" name. This can be verified by copying any library to som...
why would ldconfig create a symlink to libselinux.so.1 from libext2fs.so.2?
1,479,012,077,000
I want to scan a website's complete data, what's most authentic & user friendly tool for that on linux? Suggest me command line utilites please.
Check this tools: Metasploit Framework NIKTO Chkrootkit Nessus
Scan Website Data For Malicious Code & Injections [closed]
1,479,012,077,000
Postfix is running. I am trying to send maldet report as a mail but it gives me an error I don't know why? [root@do ~]# maldet --report 170321-0115.21534 [email protected] Linux Malware Detect v1.6 (C) 2002-2017, R-fx Networks <[email protected]> (C) 2017, Ryan MacDonald <[email protected]> Th...
The variable $mail is empty because the command mail is not installed. Run apt-get install mailx (debian or ubuntu) or yum install -y mailx (centos or redhat)
Why maldet is not sending report as a mail?
1,479,012,077,000
One of my site was infested with malware once and since then I am seeing every alternate day the header.php files are getting reverted back to older versions (possibly by a script) and a malicious script is inserted somewhere in the file: <script>var a=''; setTimeout(10); var default_keyword = encodeURIComponent(docum...
To start with, make sure your .php and .html files are NOT writable by the uid that the web server runs as. The web server needs read and execute permissions on the files and directories but (with possibly a few exceptions like upload directories) it does not need write access to the data it is supposed to be serving...
Files getting reverted to older version
1,479,012,077,000
I have some experience with Linux, currently running Ubuntu 14.04.2 LTS. I've disabled (a long time ago) root login - via ssh or webmin. I've changed my tomcat's username (good luck to the f**kers in china that is still trying "tomcat", "admin" or "root"). I have clamAv and maldetect running (finding nothing). I do ...
It could be any number of things but the page link you listed is pretty precises. Network traffic from your ip matches the pattern of an infected machine. The pattern it matches is "Win32/Zbot" so it's not likely to be your Linux box, but you also mention running a Tor Endpoint which means you effectively have no id...
Linux and being black listed
1,479,012,077,000
At my workplace we tend to get those annoying captchas once in a while when we are trying for search something in Google. When we got into that page it says that our network is trying to access Google pretty fast and in multiple times. We are suspecting that there's a computer which is infected with some kind of viru...
I would probably start by using tcpdump to find the culprit. If you have a router that runs linux (many of them do), you can often run tcpdump right on your router. If not, you could try running tcpdump (or wireshark) on a PC that's on the same network as your router. This doesn't always work because ethernet switc...
How to know which computer is trying to access a specific host
1,479,012,077,000
I have an Ubuntu 14.04 server with Apache 2.4.7 running there, hosting one site on 80 port. Today I discovered that every request to 80 port redirects to another website with response: HTTP/1.1 301 Moved Permanently Server: nginx/1.6.2 Date: Thu, 15 Jan 2015 13:37:18 GMT Content-Type: text/html Content-Length: 184 Con...
By using ip route get $IP and ip a it has been determined that the used IP address did not in fact belong to the server under investigation, so there is no mystery nginx running on this server but in fact on the server that does own that IP address.
Unknown cause for redirect on 80 port
1,479,012,077,000
My site was hacked / infected. I replaced the url of the malicious link, but other elements in the malicious script are still making my site get blocked. Without inserting a hundred or so "escapes", how can I remove the following script from 3 dozen files on my site? < script>var a=''; setTimeout(10); var def...
Firstly, I agree with the comments above: Don't use sed to recover from being hacked. You will always wonder if you missed something. Restore from backup, period. However, the literal question you asked, how to remove a long string everywhere it appears without escaping every special character, is somewhat easier to...
replace long text string (script with MANY special characters). sed, awk, grep
1,479,012,077,000
Is linux free from almost all security vulnerabilities when compared with windows? If there are so, can i install any patches to fix them? Thanks in advance.
Linux is a very secure system, however it isn't full free of vulnerabilities. There are malware known as rootkits that can get to a Unix/Linux system and steal information, destoy data,etc. However for rootkits being successful the system must be insecure / bad managed, just because a Linux system is as secure as its...
Is linux secure? [duplicate]
1,344,371,658,000
Is there a linux command that I'm overlooking that makes it possible to do something along the lines of: (pseudo) $ mkdir -R foo/bar/zoo/andsoforth Or is there no alternative but to make the directories one at a time?
$ mkdir -p foo/bar/zoo/andsoforth Parameter p stands for 'parents'.
recursive mkdir
1,344,371,658,000
I find myself repeating a lot of: mkdir longtitleproject cd longtitleproject Is there a way of doing it in one line without repeating the directory name? I'm on bash here.
This is the one-liner that you need. No other config needed: mkdir longtitleproject && cd $_ The $_ variable, in bash, is the last argument given to the previous command. In this case, the name of the directory you just created. As explained in man bash: _ At shell startup, set to the absolute pathname use...
Is there a one-liner that allows me to create a directory and move into it at the same time?
1,344,371,658,000
is there any way (what is the easiest way in bash) to combine the following: mkdir foo cd foo The manpage for mkdir does not describe anything like that, maybe there is a fancy version of mkdir? I know that cd has to be shell builtin, so the same would be true for the fancy mkdir... Aliasing?
Function? mkcdir () { mkdir -p -- "$1" && cd -P -- "$1" } Put the above code in the ~/.bashrc, ~/.zshrc or another file sourced by your shell. Then source it by running e.g. source ~/.bashrc to apply changes. After that simply run mkcdir foo or mkcdir "nested/path/in quotes". Notes: "$1" is the first argu...
Combined `mkdir` and `cd`? [duplicate]
1,344,371,658,000
mkdir -p will create a directory; it will also make parent directories as needed. Does a similar command exist for files, that will create a file and parent directories as needed?
The install utility will do this, if given the source file /dev/null. The -D argument says to create all the parent directories: anthony@Zia:~$ install -D /dev/null /tmp/a/b/c anthony@Zia:~$ ls -l /tmp/a/b/c -rwxr-xr-x 1 anthony anthony 0 Jan 30 10:31 /tmp/a/b/c Not sure if that's a bug or not—its behavior with devi...
mkdir -p for files
1,344,371,658,000
Say I have a folder: ./folder/ Inside it there are many files and even sub-directories. When I execute: mkdir -p folder I won't see any errors even warnings. So just want to confirm, is there anything lost or changed in result of this command?
mkdir -p would not give you an error if the directory already exists and the contents for the directory will not change. Manual entry for mkdir
Is mkdir -p totally safe when creating folder already exists
1,344,371,658,000
How can I create multiple nested directories in one command? mkdir -p /just/one/dir But I need to create multiple different nested directories...
mkdir accepts multiple path arguments: mkdir -p -- a/foo b/bar a/baz
Creating multiple nested directories with one command
1,344,371,658,000
Sorry if this has an answer elsewhere, I've no idea how to search for my problem. I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to create the folder was: folder = [sp.saveLocation, 'run_', sp.run_numb...
You can use the perl rename utility (aka prename or file-rename) to rename the directories. NOTE: This is not to be confused with rename from util-linux, or any other version. rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/ This uses perl's ord() function to replace each control-character in the filename with the ordin...
Why did my folder names end up like this, and how can I fix this using a script?
1,344,371,658,000
I'm curious, how many folders can be nested, and why? Is there a limit? What I mean by nested is when folders are in this structure: folder |_ folder |_ folder |_ folder |_ ... Not like this: folder |_ folder |_ folder |_ folder |_ ... If there is a limit, is it set by the operating s...
The limit will be the number of inodes on your partition since directories, like regular files, take an inode each. Nothing would stop you from creating a directory inside a directory inside another directory and so on until you run out of inodes. Note that the shell's command line does have a maximum length which c...
How many directories can be nested?
1,344,371,658,000
I want to create a directory in such a way that I need to label the directories from a to z. Inside each of these directories, I need to create sub-directories so that they are labelled as aa, ab etc. So, for instance, for the directory m, my sub-directories will be labelled as ma, mb upto mz.
Try: for x in {a..z} ; do mkdir -p $x/${x}{a..z} ; done Bash will expand XXX{a..z} out to XXXa, XXXb, and so on. There's no need for the inner loop you have. After that: $ ls a b c d e f g h i j k l m n o p q r s t u v w x y z $ ls m ma mc me mg mi mk mm mo mq ms mu mw my mb md ...
Recursively create directories for all letters
1,344,371,658,000
I have a directory foo with subdirectories. I wish to create the same subdirectories names in another directory without copying their content. How do I do this? Is there a way to get ls output as a brace expansion list?
Try this, cd /source/dir/path find . -type d -exec mkdir -p -- /destination/directory/{} \; . -type d To list directories in the current path recursively. mkdir -p -- /destination/directory/{} create directory at destination. This relies on a find that supports expanding {} in the middle of an argument word.
Create the same subfolders in another folder
1,344,371,658,000
Accidently, I ran sudo rm -r /tmp, is that a problem ? I recreated it using sudo mkdir /tmp, does that fix the problem ? After I recreated the directory, In the places section in the sidebar in nautilus in Ubuntu 14.04 I can see /tmp , which wasn't there before .. Is that a problem ? One last thing, do I have to run s...
/tmp can be considered as a typical directory in most cases. You can recreate it, give it to root (chown root:root /tmp) and set 1777 permissions on it so that everyone can use it (chmod 1777 /tmp). This operation will be even more important if your /tmp is on a separate partition (which makes it a mount point). By th...
Deleted /tmp accidently
1,344,371,658,000
In many file managers there is a shortcut/key to create a new folder. In Nautilus, Thunar, Panthon-Files, this is Ctrl+Shift+N, in Dolphin it is F10. How does this shortcut work? I imagine that behind it it's a mkdir command, but that would need a path (like discussed here). I can imagine that opening the file manage...
The new folder is not created until you actually provide a name, normally by typing something in what looks like a directory/folder name in the currently open directory/folder in the manager. Once you enter that name and press return the actual call to mkdir() is executed (not the mkdir commandline command). And if yo...
How does 'Create New Folder' short-key work?
1,344,371,658,000
This question asks for the best way to create a directory when using mv if it doesn't exist. My question is why isn't this an inbuilt feature of mv? Is there some fundamental reason due to which this would not be a good idea?
Keep in mind that there is more than one implementation of mv. The mv you use on linux is not from the exact same source as the one on OSX or Solaris, etc. But it is desirable for them all to behave in the same way -- this is the point of standards. It's conceivable that a mv implementation could add an option for t...
Will `mv` ever have the ability to create directories?
1,344,371,658,000
I have a strange issue with directory permissions. From within a C++ app, I create a folder with: mkdir( "foldername", 777 ); But I got into an issue when attempting to create a file in that folder, fopen() returned NULL, and errno told me Permission denied. So I checked, and indeed, I had the following permission...
t is not "temporary", it means that the sticky bit is set. From man ls: t [means that the] sticky bit is set (mode 1000), and is searchable or executable. (See chmod(1) or sticky(8).) The sticky bit is set here because you set decimal 777 (octal 1411), not octal 777 (decimal 511). You need to write 0777 to use octal...
Issue on created folder permissions: temporary flag
1,344,371,658,000
I am aware of the fact that mkdir -p /path/to/new/directory will create a new directory, along with parent directory (if needed ). If I have to create a new file, along with it's parent directories (where some or all of the parent directories are not present), I could use mkdir -p /path/to/directory && touch /path/to/...
AFAIK, there is nothing standard like that, but you can do it your self: ptouch() { for p do _dir="$(dirname -- "$p")" mkdir -p -- "$_dir" && touch -- "$p" done } Then you can do: ptouch /path/to/directory/file1 /path/to/directory/fil2 ...
Make parent directories while creating a new file
1,344,371,658,000
I tried to synchronize /dir1 (ext4) and /dir2 (ntfs) using rsync -azP, but got these errors: rsync: recv_generator: mkdir "dir2/X.Y." failed: Invalid argument (22) rsync: recv_generator: mkdir "dir2/CATSNDOGS\#123.11." failed: Invalid argument (22) Note that directories X.Y. and CATSNDOGS #123.11. are created by oth...
The problem is that rsync is trying to create directories in a NTFS partition with illegal characters. From Naming Conventions Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following: The following reserved ch...
Synchronizing with rsync outputs error "Invalid argument (22)" for directories with dots and other symbols in their name
1,344,371,658,000
Whenever I create new directories in my home (or its subdirectories) they do not have write permission, even though umask is set correctly. Files I make DO have write permission. [mmanary@seqap33 ~]$ umask 0002 [mmanary@seqap33 ~]$ mkdir testDir [mmanary@seqap33 ~]$ touch testFile [mmanary@seqap33 ~]$ ls -l dr-xr-x---...
Talked to the infrastructure people, and the answer is that there are extended ACLs in place that act differently based on location, and that they were erroneously set.
mkdir permissions do not correspond to umask (change depending on location)
1,344,371,658,000
I'm trying to make a directory for each file in a directory. mkdir * returns File exists. So I try mkdir *.d and it makes a directory called "*.d". How do I force the wildcard to expand?
A wildcard always expands to existing names. Your command mkdir * fails because the names that * expands to already exists. Your command mkdir *.d "fails" because the *.d does not match any existing names. The pattern is therefore left unexpanded by default1 and a directory called *.d is created. You may remove this...
Bash wildcard not expanding
1,344,371,658,000
In my scenario, I have some photos and I want to keep them separate. At present, I am doing mkdir gallery1 gallery2 gallery3 gallery4 gallery5 gallery6, but this is a pain. I think we can do it more easily. Suppose I want to make directories from gallery7 to gallery50. How would I do that?
With brace expansion. mkdir gallery{1..50}
How to create directory ranging from 1 to nth?
1,344,371,658,000
I was trying to execute a program which will create a directory on the basis of a complete path provided to it from the prompt and, if the directory already exists it will return an error (for "directory already exists") and ask again for the name in a recursive function. Here it is what I tried: let us say a file, t...
The echo always succeeds. Do without it and the subshell: #!/bin/bash echo "enter the directory name" read ab check(){ if mkdir "$ab" 2>/dev/null; then echo "directory created " ls -ld "$ab" exit else echo "try again " echo "enter new value for directory: " read ab che...
Executing a command within `if` statement and on success perform further steps
1,344,371,658,000
I am using sftp with the internal-sftp for debian. What I'm trying to acomplish is to jail all users to a specific folder which is working fine. I also need to have a single user that has "admin" rights on sftp but is not a root user. The admin user will be putting files in the sftp users directories, so they will be ...
Group varies when creating subdir: drwxrwx---+ 28 admin sftponly 4.0K Oct 22 15:19 .. dr-xrwx---+ 2 admin *users* 4.0K Oct 22 22:41 subdir Nested directory creation possibly restricted by the subdir's distinct group.
Why does default setfacl fail for nested directories?
1,344,371,658,000
I have a folder which contains some folders, these folder are moved very often so I made a script to see if they exist, and if not then create them. This is what I did to (which I though would) achieve it: if [ ! -f "$DIR/0folder" ] then mkdir "$DIR/0folder" fi But, even if 0folder already exists, it still tries to m...
The -f in your test is checking if FILE exists and is a regular file. What you need is -d to test if FILE exists and is a directory. if [ ! -d "$DIR/0folder" ] then mkdir "$DIR/0folder" fi It is not mandatory to check if a directory exists though. According to the man page of mkdir we see the following man mkdir | g...
Script tries to create files even though it shouldn't have to?
1,344,371,658,000
Suppose I have a directory /, and it contains many directories /mydir, /hisdir, /herdir, and each of those need to have a similar structure. For each directory in /, there needs to be a directory doc and within it a file doc1.txt. One might naively assume they could execute mkdir */doc touch */doc/doc1.txt but they w...
With zsh: dirs=(*(/)) mkdir -- $^dirs/doc touch -- $^dirs/doc/doc1.txt (/) is a globbing qualifier, / means to select only directories. $^array (reminiscent of rc's ^ operator) is to turn on a brace-like type of expansion on the array, so $^array/doc is like {elt1,elt2,elt3}/doc (where elt1, elt2, elt3 are the elemen...
Make many subdirectories at once
1,344,371,658,000
Quite often I need to perform this two commands: mkdir abc cd abc I am curious whether there is a simple command (or an alias that I can create and use) to do it in one go, like user@GROUP:~$ mdcd abc user@GROUP:~/abc$ Is this possible?
Add this to your .bashrc: mdcd() { mkdir "$@" && cd "$@" } Logout and login again or start a new shell to make the change.
Command for creating a directory and navigating into it directly? [duplicate]
1,344,371,658,000
I have a text file, "foo.txt", that specifies a directory in each line: data/bar/foo data/bar/foo/chum data/bar/chum/foo ... There could be millions of directories and subdirectories What is the quickest way to create all the directories in bulk, using a terminal command ? By quickest, I mean quickest to create all t...
With GNU xargs: xargs -d '\n' mkdir -p -- < foo.txt xargs will run as few mkdir commands as possible. With standard syntax: (export LC_ALL=C sed 's/[[:blank:]"\'\'']/\\&/g' < foo.txt | xargs mkdir -p --) Where it's not efficient is that mkdir -p a/b/c will attempt some mkdir("a") and possibly stat("a") and chdir("a...
What is the fastest way to create a list of directories specified in a file?
1,344,371,658,000
I want to add a few directories to the skeleton directory. When I add new user I want to add my own directories to the new home directories.
As thrig pointed out, all that's needed is to create the directory structure that you want under /etc/skel. Quoting from the useradd man page -k, --skel SKEL_DIR The skeleton directory, which contains files and directories to be copied in the user's home directory, when the home directory is created by useradd. Thi...
Skeleton directory - how to add my own directories
1,344,371,658,000
The user will be asked 2 variables which will be the name of the folder and the number of folder they want to create. So if a user inputs sea and 3, the output should be: sea, sea2, sea3 read -p "Enter the name of the folder: " NAMEFOLDER read -p "How many copies of this folder do you want?: " NUMFOLDER i=0 until [ ...
First of all, don't make your script read input at runtime. That is hard to use for your users since typos are inevitable and hard to fix, and also means the task cannot be easily repeated and automated. Instead, take the name and number as command line parameters. Next, it is bad coding style to use CAPS for local sh...
How to create folders using user input for the name and number
1,344,371,658,000
In Linux the following two commands work as expected: mkdir -m 555 new_directory mkdir -p a/b/c But the following does not work as expected: mkdir -m 555 -p a/b/c the 3 directories are created but only the latest recieves the 555 permission. The a and b directories have the default permissions. So how accomplish the...
If you expressly list the directories, parent first, you can achieve your stated aim of creating the directories in one command: mkdir -m 555 -p a a/b a/b/c With shells with support for csh-style brace expansion such as bash you can simplify this a little at the expense of readability: mkdir -m 555 -p a{,/b{,/c}} No...
How create many nested directories and defining the permission to all them in one command?
1,344,371,658,000
I'm trying to write a systemd unit file. How do I specify the path to an executable? How can I determine what to use? In this specific case I'm trying to use mkdir. ExecStartPre = "/bin/mkdir -p %h/.config/example/pending/"; This results in a error when starting the unit file though: Jan 16 08:46:11 nixos systemd[19...
Generally speaking, ${pkgs.nameOfPackage} is the preferred syntax. For your specific examplem mkdir is part of the coreutils package; which (pun intended) you can determine with the command readlink $(which mkdir). So your line should read: ExecStartPre=${pkgs.coreutils}/bin/mkdir BLAH BLAH BLAH While coreutils is al...
How do I specify a path to an executable for a systemd unit file on nix?
1,344,371,658,000
I am trying to organize my webcam picture files into folders otherwise I get thousands of pictures in one folder. I have a script foscam-move.sh (from Create sub-directories and organize files by date) with the following: #!/bin/bash for x in *.jpg; do d=$(date -r "$x" +%Y-%m-%d) mkdir -p "$d" mv -- "$x" "$d/" ...
cron doesn't run with the same environment as your user. It's likely having issues because it's not in the proper directory. Have your script cd to the directory containing the images before executing your for loop.
Sort files in a folder into dated folders
1,344,371,658,000
When I run sudo make install on a compiled package from the GNU archive, it uses mkdir -p to create the destination directories. I'd prefer it to use mkdir -p -m 0755 or install -d -m 0755 instead in order to ensure the destination directory has proper permissions for everyone under all circumstances, not just when th...
The macro AC_PROG_MKDIR_P is a feature test macro. It expands to shell code that tests for the best mkdir -p-capable command available. It uses MKDIR_P and ac_cv_path_mkdir (a "cache variable") to figure out what command to use. You may set the value of MKDIR_P to the command that you want to use for creating director...
How to make autoconf use "install" instead of "mkdir -p"?
1,344,371,658,000
I have created lots of directories and I would to make my life lazy and to auto cd into the directory that I made with the option of -g with the result of mkdir -g foo The terminal would be like this: User:/$ mkdir -g foo User:/foo/$ I have looked at this page but with no success. Is there a one-liner that allows me...
Use the command builtin to call an external command, bypassing any function of the same name. Also: What follows if is an ordinary command. To perform a string comparison, invoke the test built-in, or the [ builtin with the same syntax plus a final ], or the [[ … ]] construct which has a more relaxed syntax. See usin...
how to add a custom option to the mkdir command
1,344,371,658,000
I'm cating a file, and the output is something like this: Help me my friend Temptation Sorrow True Love Vanilla Sky I was here SOS ... I'm trying to create directory of all of these lines. What I have tried is: mkdir `cat x.txt` But the result is a mess! For instance, I was here will be split into three directories...
Read the lines one by one and use proper quoting: while IFS= read -r name; do mkdir -- "$name"; done <x.txt
Create directories from lines of a file [duplicate]
1,344,371,658,000
In Bash or Zsh, what is the shortest way to create a folder for each possible combination of substrings? Is there maybe even a notation such as mkdir {Single|Multi}Lane_{Single|Dual}Carriageway_{USA|Europe} which should result in the creation of SingleLane_SingleCarriageway_USA MultiLane_SingleCarriageway_USA SingleL...
Change the |s in your command to ,: mkdir {Single,Multi}Lane_{Single,Dual}Carriageway_{USA,Europe} 3.5.1 Brace Expansion
How can I quickly create all folders named {Single|Multi}Lane_{Single|Dual}Carriageway_{USA|Europe}
1,344,371,658,000
When I am using mkdir -pm 764 a/b/c then only c got that 764 permission, while a and b have default permission. Why does it so? Why doesn't all directories get 764 permission?
The mkdir utility creates a single directory. When used with -m it creates the directory and effectively runs chmod on it with the given permissions (although this does not happen in two steps, which could be important under some circumstances). With -p, any intermediate directories that does not already exist are cr...
Regarding permissions on intermediate folders created using "mkdir -pm 764 a/b/c"
1,344,371,658,000
I have a directory foo/ bar.txt baz.yzw wun/ a.out Now, I would like to basically add a directory in between, i.e. I would like to make it foo/ var1/ bar.txt baz.yzw wun/ a.out with the intent of also adding other stuff to foo, but kept separate from the old contents. I c...
$ cd foo $ mkdir var1 $ mv * var1 The shell and mv command are smart enough to not try to move the var1 directory into itself.
How to move a folder into itself?
1,344,371,658,000
For now i use this: mkdir -p a/b/c/d/e; touch a/b/c/d/e/file.abc; Is there more efficient ways?
In terms of tools used: no. touch will fail (rightly) if you are trying to operate in a directory that does not exist, and mkdir does precisely one thing: create directories, not normal files. Two different jobs mandate two different tools. That said, if you're talking about efficiency in terms of the number of lines ...
Create file in subdirectories that doesn't exist (../new_folder/new_folder/new_file.ext)
1,634,751,483,000
I can't find any reference of this change of behaviour $ mkdir --version mkdir (GNU coreutils) 9.0 Copyright (C) 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, t...
I compiled latest coreutils from source and I still need to use -p to create directory with parents: $ src/mkdir --version mkdir (GNU coreutils) 9.0.11-13af8 $ src/mkdir a/b src/mkdir: cannot create directory ‘a/b’: No such file or directory So you either have an alias for mkdir -p (and probably also with -v for ver...
If the `-p` flag not needed anymore in `mkdir` 9.0?
1,634,751,483,000
I'm trying to copy directory structure from src_dir to dst_dir. On my CentOS 6.4 Linux Bash this command works fine. [localhost]$ find src_dir src_dir src_dir/dir2 src_dir/dir2/dir4 src_dir/dir1 src_dir/dir1/test.txt src_dir/dir1/dir3 [localhost]$ find src_dir -type d -exec mkdir -p "dst_dir/{}" ...
Yes, that syntax is not POSIX. Only a standalone {} (on its own argument) is guaranteed to be expanded. Use: find src_dir -type d -exec sh -c 'for dir do mkdir -p "dst_dir/$dir"; done' sh {} + Or to avoid running one mkdir per directory: find src_dir -type d -exec sh -c 'for dir do set -- "$@" "dst_dir/$dir"; shi...
IBM AIX find src_dir -type d -exec mkdir -p "dst_dir/{}" \; doesn't work
1,634,751,483,000
I am pretty sure it is a stupid mistake but I can't seem to figure it out by myself, so please have a look. I set up an ACL for the current folder like so: zigbee2mqtt@nuc:/tmp/folder$ getfacl . # file: . # owner: zigbee2mqtt # group: zigbee2mqtt user::rwx user:stack:r-x user:zigbee2mqtt:rwx user:milkpirate:rwx group:...
What you see in the ls listing are the "traditional" permission bits, all you'd have in a system that doesn't support ACLs, and all that can be used by tools (or users!) that aren't ACL-aware. The "traditional" group permission bits don't correspond to the owning group ACL, but to the ACL mask (acl(5) man page): CORR...
touch/mkdir seems to ignore default ACL
1,634,751,483,000
I executed the following code in Ubuntu server 16.04 xenial: mkdir -p /root/backups/{db, dirs} I recall that in another system, it worked like charm creating all 3 dirs: /root/backups/ /root/backups/db /root backup/dirs Yet this time the result was: /root/backups/ /root/backups/{db, Why is this partial, broken resu...
Bash, like any POSIX shell, splits commands into tokens before expanding words (which, in Bash, includes brace expansion). mkdir -p /root/backups/{db, dirs} contains a space, so the command is first split into the tokens mkdir, -p, /root/backups/{db,, and dirs}. None of these need further expansion, so mkdir is run w...
mkdir -p dir with braces created wrongly
1,634,751,483,000
How can I create directories named as days of the week (i.e Monday, Tuesday, .... Saturday) inside a directory like /tmp/ in one command only? Like combination of mkdir with date +%A or any other. mkdir -p /tmp/"$(date +%A)" ---> /tmp/Tuesday Should be as below after command executes. /tmp/Monday /tmp/Tuesday . . ...
You can use the following 'command' to get the desired result: for i in {1..7}; do mkdir /tmp/$(date +"%A" --date "$i days ago"); done
One liner mkdir with directory naming as days?
1,634,751,483,000
I have separate scripts for tasks in bash. Here is the broken one: #!/bin/bash PATH=/home/name/ mkdir $PATH cd $PATH && echo "done." exit 0 Today it broke and first time it simply didn't want to run cd, but created directory. Second time it just said "mkdir command not found." Running this commands exactly with semi...
PATH is an environment variable. It's what your shell uses to find the commands it is going to run. More precisely, the PATH environment variable contains a colon-separated list of directory names, which are searched in sequence for an executable with the name that you specify when you type a command. (Unless of co...
Bash can't run command from script: mkdir command not found [closed]
1,634,751,483,000
This is fairly trivial and I'm just curious as to why mkdir ~root/.ssh is the same thing as mkdir /root/.ssh? I'm reviewing the following docker file and the creator uses mkdir ~root/.ssh to create the .ssh directory: https://github.com/macropin/docker-sshd/blob/master/Dockerfile Is there any advantage to one over th...
~USER is just a shorthand notation for the home directory of user USER. For a normal user, this would typically be /home/USER, but for root, it is typically /root. As for your question whether one is preferable to the other: The only difference is that ~root gets expanded dynamically to root's home directory, whereas...
Why is `mkdir ~root/.ssh` the same thing as `mkdir /root/.ssh`?
1,634,751,483,000
I try to understand Stephen Kitt's answer to this question where he created a temporary directory with the following code: #!/bin/bash scripttmp=$(mktemp -d) # Create a temporary directory (these will usually be created under /tmp or /var/tmp/) Each time I run this command I see a new temporary directory created und...
When using mkdir, the script would have to make sure that it creates a directory with a name that does not already exist. It would be an error to use mkdir dirname if dirname is an existing name in the current directory. When creating a temporary directory (i.e. a directory that is not needed much longer than during t...
Is there a programmatical difference between directories created with mktemp -d or mkdir?
1,634,751,483,000
I have many files in a folder Main which are named like these: 2021_10_15_23_35_SIP_CDR_pid3894_ins2_thread_1_4718.csv.gz 2021_11_24_21_15_Gi_pid25961_ins2_thread_1_6438.csv.gz 2021_11_25_20_55_Gi_pid29741_ins5_thread_4_7540.csv.gz 2021_11_24_21_15_Gi_pid27095_ins2_thread_1_6485.csv.gz 2021_11_25_20_55_Gi_pid30842_i...
Using the perl rename utility: Note: perl rename is also known as file-rename, perl-rename, or prename. Not to be confused with the rename utility from util-linux which has completely different and incompatible capabilities and command-line options. perl rename is the default rename on Debian...IIRC, it's in the pr...
Creating and arranging files into folders based on date and time in file name
1,634,751,483,000
I want to create the nested folder .aa/.bb in the current user root's home directory. So I use the command mkdir -p "~/.aa/.bb/". But it doesn't work as I expected and it created a folder ~, which I don't know how to enter into. Below is my testing. root@u2004:~# pwd /root root@u2004:~# ls -la total 28 drwx------ 3 r...
~ doesn’t have a special meaning when it’s quoted. Thus to enter your new directory: cd "~" And to fix your initial mkdir: mkdir -p ~/.aa/.bb
How to create nested folders (start with .) properly?
1,634,751,483,000
I am trying to create a directory based on the timestamp of the 2 newest files in a directory and then copy those 2 files in to the newly created directory. SO for example -rw-r--r-- 1 root root 0 Sep 24 12:01 a -rw-r--r-- 1 root root 0 Sep 24 12:01 b I want to create a directory called 20190924 and copy a and b in...
This zsh script will pick up the two newest (plain) files in the current directory, gather the modification timestamp of the most recent one, convert that timestamp to YYYYmmdd format, create the directory, then copy those two newest files into that directory: #!/bin/zsh newest2=( *(.om[1,2]) ) dsec=$( stat -c %Y "${...
Create directory with timestamp of newest files
1,634,751,483,000
I've written a script that copies some files from one place to another and since I don't have permissions to the source folder, I tried running it with sudo. The problem is that now the creation of the destination folders fails. Here is a simple test case: In my home directory the following works: mkdir testDir But ...
This is due to "root squash" on the NFS server. From the exports(5) man page (emphasis mine): nfsd bases its access control to files on the server machine on the uid and gid provided in each NFS RPC request. The normal behavior a user would expect is that she can access her files on the server just as she woul...
Sudo mkdir fails due to permission denied error
1,634,751,483,000
I am setting setuid on mkdir without making it as executable. chmod u+s /usr/bin/mkdir chmod u-x /usr/bin/mkdir [root@rhel-85 /]# ls -l /usr/bin/mkdir -rwSr-xr-x. 1 root root 84664 Jul 9 2021 /usr/bin/mkdir Now, when I login as another user "user1" I am still able to create directory even when the "mkdir" binary...
You’ve cleared the executable permission for the file’s owner, but not for members of its group or other users. As a result, the only user denied access by the permissions is root; every other user is granted permission. (root can still execute the binary, because root can execute any binary with any one of its execut...
Setting setuid on `mkdir` without making it as executable
1,634,751,483,000
| folderA1 | fileA11, fileA12, ... folderA | folderA2 | fileA21, fileA22... | ... | ... I want to make a copy of it represented as: | folderA1 | folderA11, folderA12, ... folderB | folderA2 | folderA21, folderA22, ... | ... | ... The original folderA (and it's structure) r...
You could cd into folderA and run the command from there: cd folderA find . -type d -o -type f -exec bash -c ' for path; do mkdir -p "/path/to/folderB/${path/file/folder}"; done ' bash {} + The parameter expansion ${path/file/folder} renames the each fileXY to folderXY. If every folder contains files, you can remo...
Create a folder for each file in a folder without the folder itself
1,634,751,483,000
I face the problem with $_ usage, which $_ special parameter in terminal, And its call the last argument of the previous command. It was not work with cp and mv command in gnome-terminal.It happen to me during folder creation and mv or cp file with $_ like below mkdir test cp file.c $_ instead of copying file to ...
$_ - Gives the last argument to the previous command. At the shell startup, it gives the absolute filename of the shell script being executed. When you execute mkdir test mv file.c $_ Check if your mv, cp is an alias In bash to acces the last arg to the previous command in History use !:$ ,like: > mkdir test > mv fi...
$_ not working with copy and move commands
1,634,751,483,000
I use SCP a lot to transfer log files from servers to a jumpbox where I can analyse and troubleshoot etc. If I have a cluster of servers and I want to create a set of subdirectories I do it like this: mkdir -p /foo/bar-nnn/{mailserver,dnsserver,minecraftserver,syslogserver} Lets's say 'bar-nnn' is a reference of sort...
Try this: IFS= read -r -p "Folder name: " dir mkdir -p "/foo/${dir}/"{mailserver,dnsserver,minecraftserver,syslogserver}
Create subdirectories under a parent but prompt for the name of the parent
1,634,751,483,000
On an embedded device based on Yocto Linux my rootfs is RO, while I have an additional partition for RW data. Now I want to automount at boot an overlay onto /etc stored on a different partition. Here is my fstab: /dev/mmcblk0p6 /data_local ext4 defaults,sync,noexec,rw 0 2 [...] overlay /etc overlay defaults,lowerdir=...
I ended up using the overlayfs-etc.bbclass feature from Yocto instead, which is available since Yocto 4.0. Documentation at: https://docs.yoctoproject.org/ref-manual/classes.html#ref-classes-overlayfs-etc The bbclass patches the init process in /sbin/init to create the folders at runtime before mounting the overlay. S...
fstab and systemd automount overlay
1,634,751,483,000
My question is a bit different than: Create directory using filenames and move the files to its repective folder Since in the same folder I have two similar copy of each file like: 001.txt and 001(1).txt ..... 100.txt and 100(1).txt For each two similar copies, create one folder and move both similar copies into one f...
You're nearly there. What you're missing is that you also need to try to strip the bracketed number from the filename to derive the directory: #!/bin/sh for file in *.txt do dir="${file%.txt}" # Remove suffix dir="${dir%(*)}" # Remove bracketed suffix if present mkdir -p -- "$dir" ...
Create directory using filenames and move the files to its respective folder
1,634,751,483,000
When I make install reaver in termux the following error occurs: ./install.sh -D -m 755 wash /usr/local/bin/wash mkdir: cannot create directory ‘/usr’: Read-only file system make: *** [Makefile:140: install] Error 1 I tried to mount -o remount,rw /system: mount: '/system' not in /proc/mounts I also tried mount -o rw...
I found the answer: tsudo mount -o remount,rw / *tsudo it's sudo for termux
Can't mount /system read-write
1,634,751,483,000
As in the equivalent of mkdir dir1 dir2 when running in bash. This creates two separate directories, dir1 and dir2. If you run :mkdir dir1 dir2 in ranger, it simply creates a directory called 'dir1 dir2'.
By default, ranger doesn't use mkdir flags. (I tried to pass it, and it doesn't work.) But ranger provides the use of alias. alias [newcommand] [oldcommand] Copies the oldcommand as newcommand. So when you launch ranger you can set one to execute mkdir with the flags you need. :alias mkdir shell mkdir -p An...
How to create multiple directories in Ranger?
1,634,751,483,000
I have a excel file which i will convert to csv or txt file with following data: ALFA ROMEO > 147 > Scheinwerferblenden ALFA ROMEO > 156 > Scheinwerferblenden ALFA ROMEO > 156 > Kühlergrill AUDI > 80 B3 > Heckspoiler . . and so on I need to create folders and subfolders based on this data with following syntax: ├───A...
With the input you have provided I was able to accomplish this with the following command while read -r dir; do mkdir -p ./"$dir"; done< <(sed 's@ > @/@g' input) You can replace ./ with the directory path you would like the directory tree to start in, if not the current directory. This uses sed to convert your input ...
Create folders and subfolders from csv/txt file
1,634,751,483,000
I have the following script: #------------------------ SETTINGS FOLDER_NAME="$(date '+%Y_%b_%d')" LOG_PATH=/home/alex/logs/backup-seafile-$FOLDER_NAME.log DIR_PATH=/mnt/data/Backups/Seafile FOLDER_PATH=$DIR_PATH/$FOLDER_NAME echo "--------------------------------------------" >> $LOG_PATH echo "[$(date '+%Y %b %d %H:...
The line rsync -azv --progress /mnt/data/seafile/ $FOLDER_PATH may be resetting the timestamp to that of seafile. You can work around this by touch $FOLDER_PATH after the rsync.
Folders created with script have wrong modified timestamp
1,634,751,483,000
How can I create a Nautilus script that moves a the selected file into a new folder with the same name? My starting point: /home/user/123 here 123 is a file with no extension My goal here is to achieve this result: /home/user/123/123 here we have the same file 123 inside new folder also named 123 I can't figure this o...
You can't have two files by the same name at the same time, so you'll need to first create the directory under a temporary name, then move the file into it, then rename the directory. Or alternatively rename the file to a temporary name, create the directory, and finally move the file. I see that Nautilus scripts can ...
Nautilus-script to move file into same name directory
1,634,751,483,000
I have a system which is set up with Debian. Running the command mkdir xx_ü on this system, creates a directory called 'xx_'$'\303\274'. Running the same command on a system that is set up with Ubuntu creates a directory called xx_ü which is what I would need. How do I get the system set up with Debian to create the ...
As pointed out in the comments, the problem was just the display of the folders which was messed up due to badly configured locales. Running locale on the debian system would show (note the warning here): ~> locale locale: Cannot set LC_ALL to default locale: No such file or directory LANG=en_US.UTF-8 LANGUAGE=en_US.U...
Why does mkdir messes up special characters (german umlauts)?
1,634,751,483,000
As an example, I have a directory with multiple files in this general format: dir1/identifier1_desiredName1.m dir1/identifier1_desiredName2 dir1/identifier1_desiredName3.m dir1/identifier2_desiredName1.m dir1/identifier2_desiredName2.m dir1/identifier3_desiredName1.m dir1/identifier3_desiredName2.m dir1/identifier3_de...
you can list your files in list from ls > list for example then use a loop-read of it to build sub-folders & then move the files dispatching them in the good one from its name as a pattern filter. here I made a test from empty files touch filename to demonstrate method bash-4.4$ while read > do > if [ ! -d ${REPLY/_*...
How to make multiple directories and move multiple files
1,634,751,483,000
I have the following bash script: if [ -d "/$home/DB_handouts"] then echo "Directory DB_handouts found" else mkdir /$home/DB_handouts chmod 777 /$home/DB_handouts fi Running the above code produces an error: ./file.sh: line 12: syntax error near unexpected token `else' ./file.sh: line 12: ` else' How can I fix t...
There are multiple problems with your script: there has to be a ; between the ] and then (as @heemayl also indicated) or then should be put on a line of its own there has to be a space between handouts" and ] you should (but this doesn't generate an error) consistently indent, or use the -m option for mkdir (as @skwl...
use of if else in linux to find whether the folder exists or not
1,634,751,483,000
I have the following directory structure: /media/storage/sqlbackup/CUSTOMER1 /media/storage/sqlbackup/CUSTOMER2 ... /media/storage/sqlbackup/CUSTOMER* Each CUSTOMER* directory may contain subdirectories named daily, weekly, and monthly. If a CUSTOMER* directory does not contain daily OR weekly OR monthly, I want it t...
You can create the directories while hiding any error related to the directory already existing: for custDir in /media/storage/sqlbackup/CUSTOMER* do mkdir -p "$custDir"/{daily,weekly,monthly} done You cannot use /media/storage/sqlbackup/CUSTOMER*/{daily,weekly,monthly} because the {...} sequence is expanded befo...
Find all directories NOT containing matched subdirectory and create them
1,634,751,483,000
I have a network (samba) share mounted at /run/user/1000/gvfs/smb-share:server=wdmycloud,share=family. Most activities work fine within the share - I can move stuff around, create and delete files, etc. However, if I cd into Music/Various Artists (both of which definitely exist) and try to create a specific directory,...
Colons aren’t valid characters on SMB/CIFS shares — Windows uses them for drive letters. The failing directory name contains one, which is why mkdir fails.
mkdir "No such file or directory" within a directory that exists
1,634,751,483,000
on a linux machine running CENTOS v 7.8.2003 I am in a directory Neutrinos I now do mkdir /pionloop/ this works. I then go to into this new directory pionloop and do mkdir /E_0.3 and this works as well. I thus have as a result a directory Neutrinos/pionloop/E_0.3. Now, starting in Neutrinos I want to do this in one c...
By default mkdir, does not create missing intermediate directories. As mentioned in the manual (man mkdir), you can create them with the -p flag mkdir -p pionloop/E_0.3
mkdir error: no such file or directory
1,634,751,483,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,481,306,718,000
Quick question: Is it possible to use "mkdir" to make a new directory AND change to that directory at the same time using a single 'mkdir' command? Whole question: I have this question: What single Linux “mkdir” command could replace the sequence of commands? mkdir a cd a mkdir b ...
The question you present of using a single mkdir command to do the same as the other steps doesn't really involve changing directories. It ends with cd ../.. which brings you back to the directory you were in at the start. In effect, that sequence of commands creates a directory a, then a directory b within it (in oth...
Single "mkdir" command to make a new directory and change to that directory at the same time? [duplicate]
1,481,306,718,000
Normally when I make a directory with mkdir the permissions I expect are 751 or 755. However for some reason when new files are created, even in a users home directory, they are set to 700. What controls the default permissions on new files and what kind of configuration change led to this happening?
As @Tejas mentioned, you need to understand umask and its values for changing the default permissions. I recommend you read this article so you'll understand how to use it properly. In addition, you should know that it's not permanent, so after rebooting your system the umask value you've set will be gone. To set it i...
What do are group permission missing on new directories?
1,481,306,718,000
size: 58 GB contents: unknown device: /dev/sda4 partition type: basic data When I ran the format, I selected the type which I expected result in type of Linux. I found a similar issue from 2019, but fdisk wouldn't run the solution. The file type may be suitable, but I haven't been able to run 'mkdir' on the partition...
You can't mkdir on a partition. You need to format (that's not the same as assignment of a partition type) it and mount it first
/dev/sda4/ on USB stick isn't available after formatting. 'Discs' shows the following:
1,481,306,718,000
I am trying to take a file, modify this file by using a value from a for loop (using sed) and redirecting it to a directory that has been created during the same for loop. Original file > Make directory > process file (make changes) > redirect output to directory My problem is at making the directory with the values o...
There appears to be many little things in that code snippet that may be causing confusion. First off, as written, $k can sometimes start with a dot (e.g. .1, .2, etc.), which in Unix defines the directory to be a hidden directory. The first thing I would check is whether those directories are created as hidden: ls -A ...
Creating directories inside a directory, from variable values, to redirect output from sed
1,481,306,718,000
nathan@gentoodesktop ~/Documents $ mkdir test nathan@gentoodesktop ~/Documents $ mkdir te*/test mkdir: cannot create directory 'te*/test': No such file or directory nathan@gentoodesktop ~/Documents $ cd te* nathan@gentoodesktop ~/Documents/test $ mkdir test nathan@gentoodesktop ~/Documents/test $ ls test
A pattern only ever expands to existing names, and the pattern te*/test does not match any existing name. Note that te*/test is one complete pattern and that the te* part is not matched separately from /test. Since the pattern does not match (and since the nullglob and failglob shell options are not set) it is left u...
Why does mkdir not work with wildcards? [duplicate]
1,481,306,718,000
In solaris 9 (5.9) I fail to mkdir with user builder, the user exist in the group defined as owner for that path. bash-2.05$ groups builder other root sys bash-2.05$ and this is the file structure: bash-2.05$ ls -la / | grep opt lrwxrwxrwx 1 root other 16 Apr 14 2008 opt -> /export/home/opt b...
The other group does not have write permissions in that directory. Write permissions are needed to create directory entries, such as files and subdirectories. To give the other group write permissions, as root do chmod g+w /export/home/opt
Solaris 9 Fail to mkdir - no permission
1,481,306,718,000
I have parent folder includes sub folders. In every sub folder I have folders as follow: Parent_folder folder1 folder_01_PAP_515151 folder_02_PAPA_554651 folder_03_PAPX_541313 folder_04_PAP_654123 folder2 folder_20_PAP_413513 folder_02_PAPD_521354 folder_055_PAP_685413 folder_100_PAP_132312 folder3 f...
If you have a file (named list containing, the following, and you with to create a directory for each line name in file, where the directory name is just the part after ./folder?/folder_. ./folder1/folder_01_PAP_515151 ./folder1/folder_04_PAP_654123 ./folder2/folder_055_PAP_685413 ./folder2/folder_100_PAP_132312 ./fol...
Create folders from specific parts of lines in a text file
1,481,306,718,000
I have a group of 1000+ files that are labeled using text and date in a folder /home/dir/dir2/oldspot with below format: File taken on 01/07/2020 at 23:08 elevation 5 is aaaaaa-bbbb-cc10dddd-L1-202007012308-05.std aaaaaa-bbbb-cc10dddd-L1-"year""month""date""hour""minute"-"elevation".std File taken at 02/07/2020 at ...
To simplify those directory creations, you might consider deploying the -p option to mkdir, and extending your use of "brace expansion"s like for i in {1..22} do echo mkdir -p ${elevdir}$i/0$(printf "%1d%02d" $((i/14+1)) $(((i+10)%24)))-{01..10} done mkdir -p Josef1/0111-01 Josef1/0111-02 Josef1/0111-03 ... mkd...
Sorting long list of files into multiple sub directories based on name
1,481,306,718,000
I need to manually create a directory using the following command in a cronjob and not have to enter in a password: sudo mkdir /fold1/ I have read that I should not edit /etc/sudoers directly. What are my options?
Add the script to root's cronjob: sudo crontab -e You need to be a sudoer to run the above command. You also will still have to cd to the correct directory inside your script to create your new directory in the right location.
sudo mkdir in bash script without password
1,481,306,718,000
I am trying to crate a folder with the label and uuid of a media device plugged in as its name, on another flash drive which I am using to log. I have the following code: LOGDEVICELABEL=FLASHDRIVENAME MD=`lsblk -I 8 -o label,uuid -n|sed -e '/^$/ d' -e '/^$LOGDEVICELABEL.*$/ d'` MDLOGDIR=/media/$LOGDEVICELABEL/Log/$MD ...
One thing I'll do is use echo to strip unwanted whitespace. In this context, it's important to omit any quotes: LOGDEVICELABEL=FLASHDRIVENAME MD=$(lsblk -I 8 -o label,uuid -n|sed -e '/^$/ d' -e '/^$LOGDEVICELABEL.*$/ d') MD=$(echo $MD) # <-- This line MDLOGDIR=/media/$LOGDEVICELABEL/Log/$MD mkdir $MDLOGDIR The shell...
Can't remove space from beginning of variable
1,481,306,718,000
I have a file like this with multiple rows- GSE55555 ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE55nnn/GSE55555/suppl/* ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE55nnn/GSE55555/matrix/* GSE11111 ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE11nnn/GSE11111/suppl/* ftp://ftp.ncbi.nlm.nih.gov/geo/series/GSE11nnn/GSE11111/matrix/...
Complex bash + wget solution: while read -r d f1 f2; do mkdir -p "$d" && cd "$d" wget --no-verbose -nd -np -r --level=1 "$f1" wget --no-verbose -nd -np -r --level=1 "$f2" cd $OLDPWD done <inputfile Details: read -r d f1 f2 - read 3 fields from each line from the inputfile into respective variables ...
loop over file and make dir with 1st columns and and wget using the other columns
1,481,306,718,000
Ubuntu 14.04.5 LTS GNU bash, Version 4.3.11(1)-release (x86_64-pc-linux-gnu) mkdir -vp test{1..3}/{a,b,c} works fine mkdir: created directory 'test1' mkdir: created directory 'test1/a' mkdir: created directory 'test1/b' mkdir: created directory 'test1/c' mkdir: created directory 'test2' mkdir: created directory 'tes...
Yep, in Bash, brace expansion is done as about the very first thing, before expanding variables. Which means that this doesn't work as you want: $ a=1; b=5; echo {$a..$b} {1..5} (The braces are expanded first, giving {$a..$b}, then the variables, giving {1..5}.) But you can do this (if you ever come up with a use for...
mkdir with brace expansion seems to fail when variables are used [duplicate]
1,481,306,718,000
I'm trying to make a bash script that would make a series of directories and requesting a parameter of how many directories should be created. $> ./createDir.sh 5 $> ls ex_01 ex_02 ex_03 ex_04 ex_05 I tried using mkdir ex_{01..$1} but it does not seem correct. How could I make this work (without using any loop)?
You will need eval for this. #!/bin/bash start=1 stop=$1 mkdir $(eval echo ex_{$start..$stop}) But I agree with don_crissti, why not simply use a loop? Before: ls -p | grep 'ex_' <empty> After I run the script: ./makeDirs.sh 3 ls -p | grep 'ex_' ex_1/ ex_2/ ex_3/ Further reading: Why is eval bad? Variables in b...
Creating multiple directories using a parameter in a shell script [duplicate]
1,481,306,718,000
I have a directory containing several folders with different names, and I need to create a subdirectory in each individual folder. The path for one of the folders looks like this: /Volumes/Server1/Craft/2OQ/Dom_Curr/EN/CT_1 There are multiple CT_xyz (CT_1 through CT_124) folders in the EN directory, and I need to pu...
Change into the /Volumes/Server1/Craft/2OQ/Dom_Curr/EN directory: cd /Volumes/Server1/Craft/2OQ/Dom_Curr/EN Then run the following: for D in CT_* do mkdir -p ${D}/5Misc/Permissions done This will add the subdirectories to every directory in the EN directory that begins with CT_
Create a subirectory within multiple directories
1,481,306,718,000
I have several folders ("amazon", "niger", "rhine",...). Inside each of them I have several subfolders ("gfdl", "hadgem", "ipsl",...). Each subfolders is composed by 5 subfolders (e.g. in "amazon", the subfolder "gfdl" is composed by 5 subfolder 'amazon_gfdl', 'amazon_gfdl1', ..., 'amazon_gfdl5'); and the others subfo...
You can write a tiny script to do that for you, along these lines (adjust as needed, I'm not sure I got the story right): > cat tst.sh #!/bin/bash for river in amazon niger rhine ; do for name in gfdl hadgem ipsl ; do for count in 1 2 3 4 ; do mkdir ${river}/${name}/${count} cp -a ...
Folder organization
1,481,306,718,000
I know its a big classical but I didn't found the exact situation that concerns me I need a mkdir+mv command that can be invoked like that : mvdir /home/user/Documents/irs.pdf /mnt/work/45/223/insight/irs1970.pdf Exactly like a normal mv command works, just with a creation of path instead of a no such file or directo...
Your attempt in the question is a fair stab. Here's how I would consider approaching it #!/bin/sh src=$1 dst=$2 if [ ! -d "$dst" ] then dir=${dst%/*} # dir path [ "$dir" = "$dst" ] && dir=. # but had no dir mkdir -p "$dir" # create path fi mv "$src" "$dst" ...
move and make directory