October 2013

Navigating on folder and files quick and easy


Have you ever had chance in your most busy day to realize that you always keep things doing over and over again at the same time? Asking your self that you used computer to make things easy and powerful? Well let me share to you the tools am I using and if you find this article incomplete, please comment and fill the gaps.

This time I won't demonstrate how to use every one of them coz it is really straightforward how to use it on their given documentation.


AUTOJUMP - Well due to its popularity, most people use it. It is easy to install and to use. Just keep in mind to check it's dependency package. 


FASD - This is just like autojump but I prefer this over autojump as for me it is much easier to use and I don't get confused on the keyword it uses to run in terminal. Also it has session and history of folder and files you interact with so they are blazing fast when using via SSH.

Link: https://github.com/clvv/fasd
Z - I never had a chance to use this mainly because I prefer to use fasd but yeah same purpose and function to autojump.




Now this is the bonus part, in case you are looking into something like complete package, totally old fashion but yet powerful having same features like fasd or autojump, below is you may want to check out.

FISH SHELL - This one is more way different than the tools I mentioned above but believe me it is worth trying on your machine. They also tutorials and great documentation. 




So hopefully you find this blog helpful. Cheers!

Viewing your folder and files permission Numerically

Have you ever been wondering if you could only view the folders and files permission same way like you what are doing in chmod command?


To tell you honest, I am not a good reader for this kind of format:

7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)


So I keep on searching on the web and let me share with you what I learned and found out. This procedure helps me a lot and save my day.

So let us get started.

Open your gedit and paste the code below:


#!/bin/bash



ls -lhF $1 | while read DATA

do

  case "${DATA:0:1}" in
  "-"|"d")
    PERM=$( echo "${DATA:1:9}" | sed 's/-/0/g;s/r/4/g;s/w/2/g;s/x/1/g' )
    P_US=$((${PERM:0:1}+${PERM:1:1}+${PERM:2:1}))
    P_GR=$((${PERM:3:1}+${PERM:4:1}+${PERM:5:1}))
    P_OT=$((${PERM:6:1}+${PERM:7:1}+${PERM:8:1}))
    DATA=$( echo "$DATA" | sed "s/${DATA:0:10}/${P_US}${P_GR}${P_OT}/" )
    echo "$DATA"
  ;;
  *)
    continue
  ;;
  esac
done

exit 0
#finis

Now your done. Save it as "showperm.sh" without quotes of course in safe place such as /home/[yourusername]/Documents/

Next we will create symbolic link so where ever you are in your folders, you can call it.

Open your Terminal ( ctrl + alt + t ). Go to: /usr/local/bin

I assume now your are in the bin directory. Now type this and modify the text you should alter as based on your system setup:

Syntax:
--------

ln -s [where your file reside] [where to put it]

Actual code using our example file name and folder structure:

ln -s /home/mark/Documents/showperm.sh /usr/local/bin/showperm

OR if you don't want it to rename and you are in bin folder

ln -s /home/mark/Documents/showperm.sh .

Once done. Your good to go.

In your Terminal, do this:

showperm /home/mark/

And the expected output:

755  2 mark mark 4.0K Oct  3 17:13 Desktop/
755 10 mark mark 4.0K Oct  3 08:11 Documents/
755 23 mark mark  16K Oct  3 17:13 Downloads/
755  2 mark mark 4.0K Sep 20 09:15 Music/
755  2 mark mark 4.0K Sep 23 10:06 Pictures/
755  5 mark mark 4.0K Sep 29 11:19 Videos/

Now see the most left? It is now 755 instead of seeing drwxr-xr-x

Hope you enjoy and please feel free to comment below.

Cheers!