UNIX Directories

Check

pwd

Print Working Directory

tree

exa --long --tree

Show directory tree below current directory

apt install exa

Create

mkdir /u01/mydir/mysubdir

mkdir -p /u01/mydir/mysubdir

Create mysubdir (only if /u01/mydir already exists)

Create mysubdir (also create /u01/mydir if it doesn't exist)

UNIX Directory permissions are configured using the same commands as UNIX File permissions...

Remove

rmdir /u01/mydir/mysubdir

rm -rf /u01/mydir/mysubdir

Remove mysubdir (if it is empty)

Remove mysubdir and everything in it

Navigate

cd

cd ~

cd ~/bin

cd /home/myuser/bin

cd ..

Used on its own, changes to your home directory

Changes to your home directory (as above)

Changes to a subdirectory of your home directory

Long way of doing the same as above (assuming home is /home/myuser)

Change up one level in the directory tree

pushd

popd

Comparing Directory Structures Across Servers

Generate a file containing only directories that don't exist on both servers...

PRIMARY=myHost1
STANDBY=myHost2
MYPATH=/u01/out
for host in ${PRIMARY} ${STANDBY}
do
  ssh -q ${host} find ${MYPATH} -type d
done | sort | uniq -u >/tmp/diff$$.txt

Generate a report showing which directories are missing from each server...

for host in ${PRIMARY} ${STANDBY}
do
  echo ${host}
  for file in $(cat /tmp/diff$$.txt)
  do
    ssh -q ${host} ls -ld ${file}
  done | grep "does not exist"
done

Cleanup...

rm /tmp/diff$$.txt

Bibliography