Showing posts with label ubuntu 12.04. Show all posts
Showing posts with label ubuntu 12.04. Show all posts

Tuesday 16 October 2012

Practical ls Command Examples For Fun & Profit

The power of linux lies in the shell through which we can perform complex job in no time. While the directory listing command 'ls' seems to be very simple command, the linux shell provides the power to use switches and pipes to do anything from terminal. Check out this list with practically useful examples using ls.

Display all files including hidden files/folders

ls -a


Display one file/folder per line

ls -1


Count number of files & folders

ls -1 | wc -l


Human readable file sizes (eg. Mb or Gb)

ls -lh


Alphabetically sort the listing

ls -X


Only list the folders in current directory

ls -d */
ls -p | grep /




Display folders in current directory consisting certain patterns

ls -l D* | grep :$
ls -l *a* | grep :$


List files by descending order of modification time

ls -lt
ls -l --sort=time #alternative long version


List files by descending order of creation time

ls -lct


List files in reverse order

ls -ltr
ls -l --sort=time --reverse #alternative long version


List files in descending order of file size

ls -lSh
ls -lh --sort=size
ls -lSh1 *.avi #find largest AVI file
rm `ls -S1 | head -1` #delete largest file in current folder


List files in ascending order of file size

ls -lShr
ls -lh --sort=size --reverse #alternative long version


Display directories in recursive manner

ls -R


Display the files/folders created today

ls -l --time-style=+%F | grep `date +%F`


Display the files/folders created this year

ls -l --time-style=+%y | grep `date +%y`


Any more example that fires up in your mind? Feel free to share over here ;)


Read more...

Saturday 13 October 2012

Empty Trash From Command Line In Ubuntu

CLI is such a sexy piece so why bother using GUI, even for cleaning up your trash. In this post, you will see how you can empty trash in Ubuntu from command line.

The trash you see in GUI is nothing but just the view for the files deleted by users which are temporarily moved to the special location of user's home directory. For any user, the trash location is ~/.local/share/Trash/. That is, whatever a user deletes gets saved in this location.

samar@samar-Techgaun:~$ rm -rf ~/.local/share/Trash/


I hope this becomes useful :)


Read more...

Wednesday 12 September 2012

Disable Guest Account Login In Ubuntu 12.04

Security is an important issue and I do not want anyone to access my machine, not even as the guest. Like almost every operating systems, I could see guest logon option in Ubuntu 12.04 which was turned on by default. This post provides the steps to enable or disable the guest account login in Ubuntu 12.04.

Fire up your terminal and type the following command:

samar@samar-Techgaun:~$ sudo nano /etc/lightdm/lightdm.conf

Now add a new line at the end containing the string as below:

allow-guest=false

Now reboot your system or type the following in your terminal:
samar@samar-Techgaun:~$ sudo /etc/init.d/lightdm restart

The guest account will no longer be active. If you want to enable the guest login again, just remove the line you added or change the value to true. I hope this helps :)


Read more...