• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

directory

Copy Directory Structure

August 25, 2022

Here’s how to copy a directory structure from one directory to another without the files.

Copy directory structure of DIR1 to DIR2.

find /DIR1 -type d > /tmp/dirs.txt
sed -i 's/DIR1/DIR2/' /tmp/dirs.txt 
xargs mkdir -p < /tmp/dirs.txt
chown -R USER:GROUP /DIR2

find /DIR1 -type d > /tmp/dirs.txt sed -i 's/DIR1/DIR2/' /tmp/dirs.txt xargs mkdir -p < /tmp/dirs.txt chown -R USER:GROUP /DIR2

Filed Under: Linux Tagged With: copy, directory, files, structure, without

Linux prompt display current directory only

February 11, 2022

Here’s the command to display only the current directory.

export PROMPT_DIRTRIM=1

export PROMPT_DIRTRIM=1

Place the command in your ~/.bashrc to make it permanent.

Filed Under: Linux Tagged With: current, directory, display, only, prompt

zip multiple files into one zip

December 31, 2021

How to zip multiple files into one zip file.

Using zip.

zip test.zip *.txt

zip test.zip *.txt

Using tar.

tar cvzf test.tar.gz *.txt

tar cvzf test.tar.gz *.txt

Untar in current directory or specify another directory.

tar xvzf test.tar.gz .
tar xvzf test.tar.gz -C /path/to/dir

tar xvzf test.tar.gz . tar xvzf test.tar.gz -C /path/to/dir

Filed Under: Linux Tagged With: directory, files, gzip, multiple, tar, zip

Linux Fuser

August 6, 2020

Who is accessing a particular directory? There’s a Linux command called fuser which will tell you who’s running processes in that directory.

fuser /etc/apache/
fuser /home/john/

fuser /etc/apache/ fuser /home/john/

Verbose.

fuser /data/exports/ -v

fuser /data/exports/ -v

Check out the fuser man page.

Filed Under: Linux Tagged With: directory, fuser, processes, running, who

Linux Prompt

January 20, 2020

Here’s my favorite Linux prompt.

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Add to end of your .bashrc to make it permanent.

Filed Under: Linux Tagged With: colors, directory, hostname, linux, prompt, username

  • Go to page 1
  • Go to page 2
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023