sudo -u the_user bash -s "find /path/to/directory ! -readable"
Tag: Linux
Run a command as another user
su otheruser bash -c "id"[/shell][shell]sudo -u the_user bash -s "id"
Check if the server is hosted on Google Cloud or AWS
- AWS
curl -Lso /dev/null http://169.254.169.254/latest/meta-data && echo "Definitely AWS"
if ((IWR -URI http://169.254.169.254/latest/meta-data -UseBasicParsing) -ne $null) { echo "Definitely AWS" }
- GCN
curl -Lso /dev/null -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/ && echo "Definitely GC"
PowerShell 3.0 or newer is required to send custom headers
if ((IWR -URI "http://metadata.google.internal/computeMetadata/v1/" -Headers @{"Metadata-Flavor"="Google"} -UseBasicParsing) -ne $null) { echo "Definitely GC" }
Show permissions for a file and all parent folders
namei -om /etc/nginx/nginx.conf
Check request timings using curl
(curl -s -w '\nLookup:\t%{time_namelookup}s\nConnect:\t%{time_connect}s\nPre-transfer:\t%{time_pretransfer}s\nTTFB:\t%{time_starttransfer}s\nTotal:\t%{time_total}s\n' -o /dev/null https://hub.from.support/) | column -t
Move and overwrite all files in destination, including hidden
rsync is required
--dry-run
option might be used to check what actions will be performed by rsync, without actually running them
rsync -av --remove-source-files /src/ /dest/
List available IP addresses
hostname -I