Tag: bash


List all users on a server

User information is stored in the /etc/passwd file [username@localhost /]$ awk -F":" '{ print $1 }' /etc/passwd If you want to print out the user name and UID: [username@localhost /]$ awk -F":" '{ print $1 "\t\t"$3 }' /etc/passwd | column -t Here is ...

Copy all files a user owns off of remote server

This is for copying files from a Linux machine to a local Linux machine. user@localhost the_directory> ssh user_name@remote_domain.com 'cd /dir/you/want/to/copy/; find `pwd` -user user_name' | xargs -I{} scp user_name@remote_domain.com:{} `pwd` This...

Convert string to list of ASCII codes in bash

If you want to take a string and get the ascii code for each character in the string using a bash script then use the following function: function string2ascii_codes { str=$1; list=($(echo $str|sed 's/\(.\)/\1 /g')); ascii_result=''; ...