# ls command will display all files and directories in current directory $ ls Applications Movies Desktop Music Documents Pictures Downloads Public Library #Display filesize in human readable format (e.g. KB, MB etc.,) $ls -lh total 697184 drwx------@ 4 rahul staff 136B Aug 12 10:11 Applications drwx------+ 10 rahul staff 340B Oct 4 13:04 Desktop drwx------+ 7 rahul staff 238B Sep 26 16:23 Documents drwx------+ 5 rahul staff 170B Sep 27 20:08 Downloads drwx------@ 61 rahul staff 2.0K Sep 26 17:33 Library drwx------+ 3 rahul staff 102B Jun 8 19:26 Movies drwx------+ 4 rahul staff 136B Jun 9 20:47 Music drwx------+ 3 rahul staff 102B Jun 8 19:26 Pictures drwxr-xr-x+ 5 rahul staff 170B Jun 8 19:26 Public #Order Files Based on Last Modified Time (In Reverse Order) by using ls -lrth $ls -lrth total 697184 drwxr-xr-x+ 5 rahul staff 170B Jun 8 19:26 Public drwx------+ 3 rahul staff 102B Jun 8 19:26 Pictures drwx------+ 3 rahul staff 102B Jun 8 19:26 Movies drwx------+ 4 rahul staff 136B Jun 9 20:47 Music drwx------@ 4 rahul staff 136B Aug 12 10:11 Applications drwx------+ 7 rahul staff 238B Sep 26 16:23 Documents drwx------@ 61 rahul staff 2.0K Sep 26 17:33 Library drwx------+ 5 rahul staff 170B Sep 27 20:08 Downloads drwx------+ 10 rahul staff 340B Oct 4 13:04 Desktop #To list hidden files as well in directory use ls -alrth $ls -alrth total 697288 drwxr-xr-x+ 5 rahul staff 170B Jun 8 19:26 Public drwx------+ 3 rahul staff 102B Jun 8 19:26 Pictures drwx------+ 3 rahul staff 102B Jun 8 19:26 Movies -r-------- 1 rahul staff 7B Jun 8 19:26 .CFUserTextEncoding drwxr-xr-x 6 root admin 204B Jun 8 19:30 .. drwx------ 3 rahul staff 102B Jun 9 08:01 .ssh drwx------+ 4 rahul staff 136B Jun 9 20:47 Music drwxr-xr-x 4 rahul staff 136B Jun 10 12:29 .composer -rw-r--r-- 1 rahul staff 58B Jun 11 22:46 .gitconfig -rw------- 1 rahul staff 0B Jun 21 19:37 .node_repl_history drwx------ 3 rahul staff 102B Jun 21 19:38 .config drwxr-xr-x 7 rahul staff 238B Jun 22 09:12 .npm -rw-r--r-- 1 root staff 116B Jun 27 22:53 .pearrc drwxr-xr-x 6 rahul staff 204B Jul 2 19:43 .subversion -rw------- 1 rahul staff 8.6K Jul 2 22:35 .viminfo drwx------@ 4 rahul staff 136B Aug 12 10:11 Applications drwx------+ 7 rahul staff 238B Sep 26 16:23 Documents drwx------@ 61 rahul staff 2.0K Sep 26 17:33 Library -rw-r--r--@ 1 rahul staff 12K Sep 27 11:23 .DS_Store drwx------+ 5 rahul staff 170B Sep 27 20:08 Downloads -rw------- 1 rahul staff 8.3K Oct 4 12:07 .bash_history drwx------+ 10 rahul staff 340B Oct 4 13:04 Desktop drwx------ 2 rahul staff 68B Oct 4 19:26 .Trash drwxr-xr-x+ 26 rahul staff 884B Oct 4 19:26 . drwx------ 32 rahul staff 1.1K Oct 4 21:22 .bash_sessions
#display absolute path of current working directory $ pwd /Users/rahul/Desktop
#Use cd to switch between directories $ cd Movies
#To create new directory $ mkdir MyFolder #To create new directory with name having space i.e. "My Folder" $ mkdir My\ Folder #Or To create new directory with name having space i.e. "My Folder" $ mkdir "My Folder" #To create multiple directories in one shot $ mkdir MyFolder1 MyFolder2 MyFolder3
#To delete file in Linux $ rm index.php #To delete directory containing files and folders $ rm -r MyFolder #To delete directory containing files and folders forcefully $ rm -rf MyFolder
#To create empty files $ touch index.php #To create multiple empty files $ touch index.php home.php login.php
#To make a copy of files $ cp /home/htdocs/codephponline/index.php /home/Desktop/ #To make a copy of directory $ cp -r /home/htdocs/codephponline /home/Desktop/
#To move files/folders from one location to other $ mv /home/htdocs/codephponline/index.php /home/Desktop/ #To rename file $ mv /home/htdocs/codephponline/index.php /home/htdocs/codephponline/main.php
#Create tar Archive File $ tar -cvf codephponline.tar /home/codephponline #Create tar.gz Archive File $ tar -cvzf codephponline.tar.gz /home/codephponline #Untar tar Archive File $ tar -xvf codephponline.tar #Uncompress tar.gz Archive File $ tar -xvf codephponline.tar.gz #List Content of tar Archive File $ tar -tvf codephponline.tar #List Content tar.gz Archive File $ tar -tvf codephponline.tar.gz
#To search file named ReadMe.txt $ locate ReadMe.txt #To search all file having extension .txt $ locate *.txt
#wipes the linux terminal clean $ clear
Technical Architect
Kuala Lumpur, Malaysia
I'm a Full Stack Web Developer working in a MNC and passionate of developing modern web and mobile applications.
I have designed and developed CodephpOnline & CodephpOnline Wiki platform to expatiate my coding and technology learning experiences.
In my leisure time, I write technical articles on web development such as PHP, Laravel, CodeIgniter, Mediawiki, Linux, Angular, Ionic, ReactJS, NodeJS, AJAX, jQuery, Cloud and more.