#files
12 one-liners with this tag.
All one-liners tagged files
Copy a file
$cp -ip -- /var/www/vhosts/example.com/httpdocs/.htaccess /var/www/vhosts/example.com/private/htaccess-copy
Create a dated backup copy of a file
$cp -p -- /var/www/vhosts/example.com/httpdocs/.htaccess /var/www/vhosts/example.com/httpdocs/.htaccess.bak-$(date +%F-%H%M)
Delete a file
$rm -i -- /var/www/vhosts/example.com/httpdocs/old.zip
Find a file by name
$find /var/www/vhosts -iname '*wp-config*' 2>/dev/null
List directory contents with permissions and sizes
$ls -lAh --group-directories-first -- /var/www/vhosts/example.com/httpdocs
Move a file to another directory
$mv -i -- /var/www/vhosts/example.com/httpdocs/old.zip /var/www/vhosts/example.com/private/
Rename a file or directory
$mv -i -- /var/www/vhosts/example.com/httpdocs/index.html /var/www/vhosts/example.com/httpdocs/index.html.old
Rename many files at once
$rename -n 's/\.jpeg$/.jpg/' *.jpeg
Copy a file from a Docker container to the host
#docker cp app:/etc/nginx/nginx.conf /root/nginx.conf
Find the package that provides a file not yet installed
$apt-file search bin/mysqldump
Find which installed package a file belongs to
$dpkg -S /usr/bin/curl
Show open files of a process
#lsof -p 1234