Tag Info

Hot answers tagged

15

The literal answer is that there is no such thing as an untrusted application running under your account. If you want to run an untrusted application, run it under a different account or in a virtual machine. Typical desktop operating systems such as Unix and Windows and typical mobile operating systems such as Android and iOS have different security ...


12

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 | grep -A1 -- -p -p, --parents ...


10

$ inotifywait -m /tmp Setting up watches. Watches established. /tmp/ CREATE file.ext.filepart /tmp/ OPEN file.ext.filepart /tmp/ MODIFY file.ext.filepart /tmp/ CLOSE_WRITE,CLOSE file.ext.filepart /tmp/ CREATE file.ext /tmp/ DELETE file.ext.filepart Transcript from running $ echo hello >/tmp/file.ext.filepart $ ln /tmp/file.ext.filepart /tmp/file.ext ...


10

The system does not track that information. Every time the file is modified, the new modification time overwrites the previous one. Depending on what exactly you need to do, various alternate solutions might apply, such as using a version control system, or having a daemon that watches for changes using inotify. But all of those solutions would rely on ...


8

You need the write permission on a directory to create or remove files in it, but not to write to a file in it. Most shell commands, when given an output file, simply open that file for writing, and replace the data that was previously in the file. The > redirection operator truncates the existing file (i.e. deletes the existing file content, resulting in ...


6

With a large enough value of 'undolevel', Vim should be able to undo the whole day's changes. If you quit Vim in between, you also need to enable persistent undo by setting the 'undofile' option. Vim captures not just a sequential list of commands for undo, but actually a tree of all changes. It also has several commands around undo (cp. :help ...


6

Try this: touch -d"April 13 3 AM" file1 touch -d"April 13 9 AM" file2 find . -newer file1 ! -newer file2 -exec grep -l "pcV6URY" {} + rm file1 file2 How it works find can work directly with times but touch handles human-style dates better: touch -d"April 13 3 AM" file1; touch -d"April 13 9 AM" file2 This creates two files to mark the beginning and end ...


5

You will receive in destination_dir files with full path from / find /path/git_directory -type f -iname "*.py" \ -exec cp --parents -t /path/destination_dir {} + Other solution is rsync rsync -Rr --prune-empty-dirs \ --include="*.py" \ --include="**/" \ --exclude="*" \ /path/git_directory ...


5

You can try to set umask before converting it umask 077; openssl rsa -in secure.key -out insecure.key Edit: To not affect other files in the current shell environment by the umask setting execute it in a subshell: ( umask 077; openssl rsa -in secure.key -out insecure.key )


4

It's not possible because ctime is changed always if there is a change of mtime. Here is the explanation: Let's see from file perspective: ctime is the inode/file change time, it means that ctime is updated when the file attributes are changed, like changing the owner or the permission. mtime is the file modify time, it's updated when you modify the ...


4

AFAICT, no. The problem is that the gzip process will create a new file and will free the previous (the unzipped) one, including a removal from the directory. If no other hard-link in the filesystem is pointing to the file it will get lost once the last file descriptor refering to it is closed. For the future you'd be advised to synchronize the access to ...


4

If I undersood the question correctly you need files in myfiles which do not have symlinks in images: #!/bin/bash OIFS="$IFS" IFS=$'\n' files="$(find myfiles/ -type f -name '*.jpg' -or -name '*.cr2')" for f in $files; do list="$(find -L images/ -xtype l -samefile "$f")" if [[ "$list" == "" ]]; then echo "$f does not have symlink." fi ...


4

On a POSIX filesystem, every file has a user (the file's owner), a group, and permissions for the user, the group, and everyone else. For every user, access to a given file is determined as follows: if the user is the file's owner, the owner permissions apply; if the user is a member of the file's group, the group permissions apply; in all other cases, ...


4

Without something like SELinux, root can always write to files; since you're running as root you can always write. If you're not running as root, then the permissions apply; if file exists and is not writable, then > file or >> file will fail. If file does not exist, then it will be created if the parent directory is writable.


3

Here is one way (put it in a file and execute it with any POSIX shell like bash or ksh): cd ~/somefolder/ || exit 1 for f in *.png do case $f in (tn_*) continue ;; (*) convert "${f}" -resize 50%x50% "tn_${f}" ;; esac done With modern shells the case construct could also be replaced by a terser conditional command: cd ~/somefolder/ || exit 1 for f ...


3

With zsh: print -rl ${(0)^"$(locate -0 ...)"}(N.) (0) is a parameter expansion flag that splits on NUL characters (as we use locate -0), short for (ps:\0:). With ^, instead of adding (N.) at the end of the array, we add it to each element. (N.) is a glob qualifier, . to match only regular files, N to remove the element if it doesn't match (doesn't exist ...


3

This is about as inelegant as the other answers, but maybe less inefficient: locate --regex --basename "xfce4-keyboard-overlay$" | while IFS= read -r f; do [ -f "$f" ] && printf "%s\n" "$f"; done (broken into two lines for readability).  The above will handle names containing spaces.  The IFS= seems to be necessary to handle names with ...


3

ls itself won't show this information. You can pipe the output of the find to file -f -, as follows: $ find /usr/local/bin | file -f - /usr/local/bin: directory /usr/local/bin/apt: Python script, ASCII text executable /usr/local/bin/mint-md5sum: ASCII text /usr/local/bin/search: ...


3

65534 is some kind of default/nobody UID & GID value. Your VPS provider made some sort of mistake when they copied over your container. For example they used rsync but failed to use its --numeric-ids option. The user IDs inside your container don't exist outside the container and some copy tools, upon seeing UIDs and GIDs that they can't resolve, revert ...


3

find . -name PKA.dump -type f -exec awk ' FNR == 20 {print; nextfile}' {} + nextfile, where available (GNU awk and some others like FreeBSD's and recent versions of mawk and soon to be added to the standard) will skip to the next file. Where not, it will be ignored (it's just like dereferencing a nextfile variable); it will still work but read the files ...


3

From the manual (man bash) under CONDITIONAL EXPRESSIONS: -f file True if file exists and is a regular file. -d file True if file exists and is a directory. So, to check for the existence of a directory (not a file)... if [[ ! -d "$DIR/0folder" ]] ; then mkdir "$DIR/0folder" fi


3

You don't need a text file, you can use this: base64 <<< "$var" or echo "$var" | base64 Example: var="abcde" base64 <<< "$var" results YWJjZGUK


3

If the directory is read-only but the files within that directory are read/write, then there is nothing stopping you from overwriting those files. From a script you can write to the files using usual redirection > and >> as well as overwriting them using cp. What you cannot do is to create a new file in the directory and rename it on top of an ...


3

Perl's Tie::File module offers true in-place edit functionality: perl -MTie::File -e ' tie @a,"Tie::File","your_file_here"; # Do something... ' This makes the elements of @a into the lines of your file and any changes done to @a are reflected in the file even if the file is in a read-only directory.


2

There are two possibilities: 1) You need to look at the owner/group permissions of the directory containing the file or directory you try to delete as that entry will be modified if a file (or directory) within it is deleted. 2) The account (group membership) of user xyz is modified but the user is not using a new shell and therefore the new group ...


2

Here the answers: root has always full access to files and directories. The owner of the file usually has them too, but this is not always true. For example: -r-xr----- 1 user1 users 199 Oct 14 18:42 otherfile.bin user1 is the owner; however he can only read and execute, but root still has full access (rwx) to the file. RUID is the Real User ID and it ...


2

I had a similar problem when using rsync to backup my system to my server. I used: rsync -aAXSHPr \ -e ssh \ --rsync-path="sudo /usr/bin/rsync/" \ --numeric-ids \ --delete \ --progress \ --exclude-from="/path/to/file/that/lists/excluded/folders.txt" \ --include-from="/path/to/file/that/lists/included/folders.txt" \ / ...


2

As the other answers have stated: Yes, the file can be edited/modified.  And, at the risk of splitting hairs, allow me to point out that the question says … he has [write permission] on a file under [the directory]. and to make the semi-obvious comment that, to edit a file in the traditional meaning of the word, the user must also have read permission ...


2

I assume that the files under myfiles are not symbolic links, and that none of the file names contain newlines. (My approach can still work if these assumptions are violated but it gets more complicated.) I also assume that you have the common readlink utility and that it supports -f to canonicalize paths, which is the case on Linux (both GNU and BusyBox), ...


2

A file rename that doesn't cross file system boundaries is just a metadata change, so it should preserve the inode number. Generally speaking, opening a file and modifying its contents should not change its inode number, which only makes sense within a single file system anyway (but it will change the access times, for example). Note that some tools such as ...



Only top voted, non community-wiki answers of a minimum length are eligible