Here’s the command to display only the current directory.
export PROMPT_DIRTRIM=1 |
Place the command in your ~/.bashrc to make it permanent.
cloud engineer
by Ulysses
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.
by Ulysses
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
by Ulysses
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.
by Ulysses
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.
by Ulysses
Here are two important tar commands on how to create and extract a tar.gz file.
Create a tar gzip file called “project.tar.gz” of a directory called “foo.”
tar -cvzf project.tar.gz foo |
tar -cvzf project.tar.gz foo
Untar the “project.tar.gz” file to a directory called bar.
tar -xvzf project.tar.gz bar |
tar -xvzf project.tar.gz bar
by Ulysses
Here’s how to get the size of a directory.
du -sh /var/www |
du -sh /var/www
Output:
2.1GB /var/www |
2.1GB /var/www
Size of the directories and files one level down.
du -sh /var/www/* |
du -sh /var/www/*
Sort with biggest files from top to bottom.
du -sh /var/www/* | sort -rh |
du -sh /var/www/* | sort -rh
Top 5 biggest files from top to bottom.
du -sh /var/www/* | sort -rh | head -5 |
du -sh /var/www/* | sort -rh | head -5
by Ulysses
Moving a Linux directory the safe way.
cd /mydir ; tar cf - . | (cd /data/mydir ; tar xf -) ; mv /mydir /mydir.0 ; ln -s /data/mydir /mydir |
cd /mydir ; tar cf - . | (cd /data/mydir ; tar xf -) ; mv /mydir /mydir.0 ; ln -s /data/mydir /mydir