An ls (pronouced as el es) utility appeared in the original version of AT&T UNIX. Today, two popular versions of ls are the Free Software Foundation’s (part of the GNU coreutils package) and the one released by various BSD variants, such as FreeBSD, OpenBSD, NetBSD, and Apple Computer’s Darwin. Both are free software and open source.
The ls command is one of the most used and important command that we as linux user and linux/unix administrator can’t live without. It is the basic utility that a beginner must learn and one of the commands that a Unix/Linux administrator should not forget. In this article, we will explore on how we can use the ls more efficiently and take advantage about its power.
1. Opening the last file edited.
To open the last edited file in the current directory use the combination of ls, head and vi commands as shown below. ls -t sorts the file by modification time, showing the last edited file first. head -1 picks up this first file.
$ nano `ls -t | head -1`
Be aware with the tick `, because it is important to make the command work.
2. Display one file per line.
To display files and directories per line, use -1.
$ ls -1ApplicationsDesktopDocumentsDownloadsxincoClientConfig.dat
$ ls -ldrwxr-xr-x 2 johndoe staff 68 Feb 18 2011 Applicationsdrwx——+ 30 johndoe staff 1020 Feb 17 16:21 Desktopdrwx——+ 126 johndoe staff 4284 Feb 17 15:01 Documentsdrwx——+ 63 johndoe staff 2142 Feb 19 22:25 Downloads-rw-r–r– 1 johndoe staff 20960 Jun 6 2011 xincoClientConfig.dat
$ ls -l-rw-r–r– 1 johndoe staff 20960 Jun 6 2011 xincoClientConfig.dat
$ ls -lh-rw-r–r– 1 johndoe staff 20K Jun 6 2011 xincoClientConfig.dat
- Lordfrancis3 is a member of PinoyLinux since its establishment in 2011. With a wealth of experience spanning numerous years, he possesses a profound understanding of managing and deploying intricate infrastructure. His contributions have undoubtedly played a pivotal role in shaping the community's growth and success. His expertise and dedication reflect in every aspect of the journey, as PinoyLinux continues to champion the ideals of Linux and open-source technology. LordFrancis3's extensive experience remains an invaluable asset, and his commitment inspires fellow members to reach new heights. His enduring dedication to PinoyLinux's evolution is truly commendable.
- Software and TechnologySeptember 18, 2023Nginx Reverse Proxy with Redis for Rate Limiting and Queues for Performance Optimization
- System AdminstrationAugust 27, 2023Automating Yourself Out of Your Job
- Privacy and SecurityAugust 22, 2023Security Alert: Privilege Escalation Vulnerability Impacts Over 10,000 Charitable WordPress Sites
- ServersAugust 14, 2023Why Red Hat Abandoned CentOS 7 and the Best Alternatives