Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the ls command in linux

Shulou Source: shulou.com Published: 2022-06-01 04:19:00 10月01日 Update

This article mainly shows you "how to use ls commands in linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use ls commands in linux" this article.

Ls

If you know where the files are, you just need to list them or view information about them, and that's why ls is born.

Simply run ls to list all the visible files and directories in the current directory:

$lsDocuments Music Pictures Videos notes.txt

Add the-l option to view information about the file. At the same time, add the-h option to view the file size in a format that is easy for people to read:

$ls-lhtotal 60Kdrwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Documentsdrwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Musicdrwxr-xr-x 2 adam adam 4.0K Nov 2 13:13 Picturesdrwxr-xr-x 2 adam adam 4.0K Nov 2 13:07 Videos-rw-r--r-- 1 adam adam 43K Nov 2 13:12 notes.txt

Ls can also search for a specified location:

$ls Pictures/trees.png wallpaper.png

Or a specified file-- even if only part of the name:

$ls * .txtnotes.txt

What's missing? Want to view a hidden file? No problem, use the-an option:

$ls-a. .bash _ logout .bashrc Documents Pictures notes.txt.. .bash _ profile .vimrc Music Videos

Ls has many other useful options that you can combine to get the effect you want. You can learn more using the following command:

The above $man ls is all the contents of this article entitled "how to use ls commands in linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Files commands content articles information more directories learning help for this people location just can make at the same time name size that is effect easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Redmi Shulou Information MariaDB