![]() To get the names of all the files along with their size, use the -s flag with the command. This means that ls /usr/home -R is a valid command. Note that you can also pass the directory path along with the recursive flag. Using the -R flag with the default command will list down all the files and folders present inside a directory down to the last level. Using the * character with the ls command will provide you with a list of all the files and folders in the current working directory, along with the sub-directories as well. ls -d /home List Files With Sub-Directories If for any reason you only want to list folders present in a directory, use the -d flag with the default ls command. ![]() Therefore, to list the content available in your home directory: ls ~ List Only Directories (No Files) The home directory in Linux is denoted by the ~ character. cache db empty games lib local lock log mail opt run spool tmp List Files in the Home Directory will provide you with a list of all the files and folders contained in the /var directory. will list the folders present in the /log directory whereas ls. For example, /var/log/old is your current working directory. will take you to the parent directory of the parent directory. bin etc include lib lib32 lib64 local sbin share srcĪdding another. To get a list of all the files in a parent directory: ls. Here, /bin is your current working directory, and /usr is the parent directory. List Files in the Parent DirectoryĪ parent directory in Linux is a directory above the current directory. It doesn't matter which directory you're in at the time of entering the command, the above-mentioned command will produce an output that lists all the sub-folders and files present inside the root directory. A root directory is generally denoted by the / character. It is the top-most folder in your computer's directory-hierarchy. The root directory contains all the other directories and files on your system. ls /boot /usr OutputĮFI grub initramfs-linux-fallback.img initramfs-linux.img vmlinuz-linuxīin etc include lib lib32 lib64 local sbin share src List Files in the Root Directory You can also pass multiple directories by separating the path names with a Space character. ![]() EFI/ grub/ initramfs-linux-fallback.img initramfs-linux.img vmlinuz-linux Using the -F flag with the command will add a / character at the end of every directory. EFI grub initramfs-linux-fallback.img initramfs-linux.img vmlinuz-linux The output will now show the files and folders present in the directory name provided. To get the list of all the files present in the /boot directory: ls /boot bin dev home lib64 mnt proc run srv tmp varīoot etc lib lost+found opt root sbin sys usr Listing Files in a Specific Directoryįor listing files that belong to a different folder (not the current working directory), you will have to pass the directory path along with the command name. If you execute the aforementioned statement in your system's root directory, you will see an output that looks something like this. One of the most simple use of the command is to list all the files and folders in your current working directory. The basic syntax of the ls command is: ls
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |