20150309-2 选题

This commit is contained in:
DeadFire 2015-03-09 16:54:48 +08:00
parent 9bde39c07d
commit e299e3dbf4
3 changed files with 616 additions and 0 deletions

View File

@ -0,0 +1,167 @@
10 Useful ls Command Interview Questions Part 2
================================================================================
Continuing the legacy of ls command here is the second interview article on Listing command. The first article of the series was highly appreciated by the Tecmint Community. If youve missed the first part of this series you may like to visit at:
- [15 Interview Questions on “ls” Command Part 1][1]
This article is well presented in the manner that it gives deep insight of ls command with examples. We have taken extra care in the making of article so that it remains simple to understand yet serve the purpose to the fullest.
![10 Interview Questions on ls Command](http://www.tecmint.com/wp-content/uploads/2015/03/ls-Command-Interview-Questions.jpg)
10 Interview Questions on ls Command
### 1. You are supposed to list the content of a directory in long list format, but not print the name of the author and group the file belongs. Also show the difference in output. ###
a. ls command listing the name of the files in long listing format when used with switch (-l).
# ls -l
![List Files in- Long List Format](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-inLong-List-Format.gif)
List Files in- Long List Format
b. ls command listing the name of the files in long listing format along with the name of the author file belongs, when used with switch (author) along with switch (-l).
# ls -l --author
![List Files By Author](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-By-Author.gif)
List Files By Author
c. ls command listing the name of the files without the name of its owner, when used with switch (-g).
# ls -g
![List Files Without Printing Owner Name](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-Without-Printing-Author.gif)
List Files Without Printing Owner Name
d. ls command listing the name of files in long listing format without the name of group it belongs, when used with switch (-G) along with switch (-l).
# ls -Gl
![List Files Without Printing Group](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-Without-Printing-Group.gif)
List Files Without Printing Group
### 2. Print the size of files and folders in the current directory, in human readable format. How will you do this? ###
Well we need to use switch -h (human-readable) along with switch (-l) and/or (-s) with the command ls to get the desired output.
# ls -hl
![List Files in Human Readable Format](http://www.tecmint.com/wp-content/uploads/2015/03/List-Size-of-Files-with-ls.gif)
List Files in Human Readable Format
# ls -hs
![List File Sizes in Long List Format](http://www.tecmint.com/wp-content/uploads/2015/03/List-File-Sizes-in-Readable-Format.gif)
List File Sizes in Long List Format
**Note**: The option -h uses the power of 1024 (standard in computation) and output the size of files and folders in the units of K, M and G.
### 3. Well if switch (-h) output size in power of 1024, that is standard, What else power values are supported in ls command? ###
There exist a switch -si which is similar to switch -h. The only difference is switch -si uses power of 1000 unlike switch -h which uses the power of 1024.
# ls -si
![Supported Power Values of ls Command](http://www.tecmint.com/wp-content/uploads/2015/03/ls-supported-power-values.gif)
Supported Power Values of ls Command
It can also be used with switch -l to output the size of folder in the power of 1000, in long listing format.
# ls -si -l
![List Files by Power Values](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-by-Power-Values.gif)
List Files by Power Values
### 4. You are supposed to print the contents of a directory separated with comma. Is it possible? Can it be done in long listing format? ###
Yup! Linux ls command can output the contents of a directory separated by comma when used with the switch (-m). Since this comma separated entries are filled horizontally, ls command cant separate contents with comma when listing contents vertically.
# ls -m
![Print Contents of Directory by Comma](http://www.tecmint.com/wp-content/uploads/2015/03/Print-Contents-of-Directory-by-Comma.gif)
Print Contents of Directory by Comma
When used in long listing format, switch -m gets useless.
# ls -ml
![Listing Content Horizontally](http://www.tecmint.com/wp-content/uploads/2015/03/Listing-Content-Horizentally.gif)
Listing Content Horizontally
### 5. If there any way to print the contents of a directory upside down? i.e., in reverse order. ###
Yeah! The above situation can easily be achieved using the switch -r. The switch -r reverse the order of output. It can also be used with switch -l (long listing format).
# ls -r
![List Content in Reverse Order](http://www.tecmint.com/wp-content/uploads/2015/03/List-Content-in-Reverse-Order.gif)
List Content in Reverse Order
# ls -rl
![Long List Content in Reverse Order](http://www.tecmint.com/wp-content/uploads/2015/03/Long-List-Content-in-Reverse-Order.gif)
Long List Content in Reverse Order
### 6. You are given a situation to print the sub-directories recursively. How will you achieve this situation? Mind it only sub directories and no files. ###
Okay! That is pretty easy with the switch -R when used with command ls. It can further be grouped with other options like -l (long list) and -m (comma separated), etc.
# ls -R
![Print Sub Directories in Recursively](http://www.tecmint.com/wp-content/uploads/2015/03/Print-Sub-Directories-in-Recursively.gif)
Print Sub Directories in Recursively
### 7. How to sort the files based upon the size? ###
The Linux command line option -S when used with ls gives the desired output. To sort the files based upon size in descending order with the largest file listed at first and smallest at last.
# ls -S
![Sort Files with ls Command](http://www.tecmint.com/wp-content/uploads/2015/03/Sort-Files-in-Linux.gif)
Sort Files with ls Command
To sort the files based upon size in descending order with the smallest file listed at first and largest at last.
# ls -Sr
![Sort Files in Descending Order](http://www.tecmint.com/wp-content/uploads/2015/03/Sort-Files-in-Descending-Order.gif)
Sort Files in Descending Order
### 8. List the contents of a directory with no additional information appearing one file per line. ###
The switch -1 comes to rescue here. ls command with switch -1 output the contents of the directory with one file per line and no additional information.
# ls -1
![List Files Without Information](http://www.tecmint.com/wp-content/uploads/2015/03/List-Files-Without-Information.gif)
List Files Without Information
### 9. You are given a situation in which you have to print the contents of a directory on standard output enclosed by double quotes. How will you do this? ###
There exist an option -Q (quote-name) which output the content of ls enclosed in double quotes.
# ls -Q
![Print Files with Double Quotes](http://www.tecmint.com/wp-content/uploads/2015/03/Print-Files-with-Double-Quotes.gif)
Print Files with Double Quotes
### 10. You are working in a directory which contains lots of files and folders. You need to print the name of folders before directories. How will you get this? ###
# ls --group-directories-first
![Print Directories First](http://www.tecmint.com/wp-content/uploads/2015/03/Print-Directories-First.gif)
Print Directories First
Thats all for now. We will be coming up with the next part of this article series very soon. Till then stay tuned and connected to Tecmint. Do not forget to provide us with valuable feedback in the comment section below. Like and share us and help us get spread!
--------------------------------------------------------------------------------
via: http://www.tecmint.com/ls-interview-questions/
作者:[Ravi Saive][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/admin/
[1]:http://www.tecmint.com/ls-command-interview-questions/

View File

@ -0,0 +1,262 @@
15 Basic ls Command Examples in Linux
================================================================================
ls command is one of the most frequently used command in Linux. I believe ls command is the first command you may use when you get into the command prompt of Linux Box. We use ls command daily basis and frequently even though we may not aware and never use all the option available. In this article, well be discussing basic ls command where we have tried to cover as much parameters as possible.
![Linux ls Command](http://www.tecmint.com/wp-content/uploads/2012/08/Linux-ls-Commands.png)
Linux ls Command
### 1. List Files using ls with no option ###
ls with no option list files and directories in bare format where we wont be able to view details like file types, size, modified date and time, permission and links etc.
# ls
0001.pcap Desktop Downloads index.html install.log.syslog Pictures Templates
anaconda-ks.cfg Documents fbcmd_update.php install.log Music Public Videos
### 2 List Files With option l ###
Here, ls -l (-l is character not one) shows file or directory, size, modified date and time, file or folder name and owner of file and its permission.
# ls -l
total 176
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
### 3. View Hidden Files ###
List all files including hidden file starting with ..
# ls -a
. .bashrc Documents .gconfd install.log .nautilus .pulse-cookie
.. .cache Downloads .gnome2 install.log.syslog .netstat.swp .recently-used.xbel
0001.pcap .config .elinks .gnome2_private .kde .opera .spice-vdagent
anaconda-ks.cfg .cshrc .esd_auth .gtk-bookmarks .libreoffice Pictures .tcshrc
.bash_history .dbus .fbcmd .gvfs .local .pki Templates
.bash_logout Desktop fbcmd_update.php .ICEauthority .mozilla Public Videos
.bash_profile .digrc .gconf index.html Music .pulse .wireshark
### 4. List Files with Human Readable Format with option -lh ###
With combination of -lh option, shows sizes in human readable format.
# ls -lh
total 176K
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
-rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 21K Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 46K Jul 31 09:58 index.html
-rw-r--r--. 1 root root 48K Jul 31 02:17 install.log
-rw-r--r--. 1 root root 12K Jul 31 02:13 install.log.syslog
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Videos
### 5. List Files and Directories with / Character at the end ###
Using -F option with ls command, will add the / Character at the end each directory.
# ls -F
0001.pcap Desktop/ Downloads/ index.html install.log.syslog Pictures/ Templates/
anaconda-ks.cfg Documents/ fbcmd_update.php install.log Music/ Public/ Videos/
### 6. List Files in Reverse Order ###
The following command with ls -r option display files and directories in reverse order.
# ls -r
Videos Public Music install.log fbcmd_update.php Documents anaconda-ks.cfg
Templates Pictures install.log.syslog index.html Downloads Desktop 0001.pcap
### 7. Recursively list Sub-Directories ###
ls -R option will list very long listing directory trees. See an example of output of the command.
# ls -R
total 1384
-rw-------. 1 root root 33408 Aug 8 17:25 anaconda.log
-rw-------. 1 root root 30508 Aug 8 17:25 anaconda.program.log
./httpd:
total 132
-rw-r--r-- 1 root root 0 Aug 19 03:14 access_log
-rw-r--r--. 1 root root 61916 Aug 10 17:55 access_log-20120812
./lighttpd:
total 68
-rw-r--r-- 1 lighttpd lighttpd 7858 Aug 21 15:26 access.log
-rw-r--r--. 1 lighttpd lighttpd 37531 Aug 17 18:21 access.log-20120819
./nginx:
total 12
-rw-r--r--. 1 root root 0 Aug 12 03:17 access.log
-rw-r--r--. 1 root root 390 Aug 12 03:17 access.log-20120812.gz
### 8. Reverse Output Order ###
With combination of -ltr will shows latest modification file or directory date as last.
# ls -ltr
total 176
-rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
### 9. Sort Files by File Size ###
With combination of -lS displays file size in order, will display big in size first.
# ls -lS
total 176
-rw-r--r--. 1 root root 48867 Jul 31 02:17 install.log
-rw-r--r--. 1 root root 46701 Jul 31 09:58 index.html
-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php
-rw-r--r--. 1 root root 11439 Jul 31 02:13 install.log.syslog
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents
drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Music
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Pictures
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Public
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Templates
drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Videos
-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg
-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap
### 10. Display Inode number of File or Directory ###
We can see some number printed before file / directory name. With -i options list file / directory with inode number.
# ls -i
20112 0001.pcap 23610 Documents 23793 index.html 23611 Music 23597 Templates
23564 anaconda-ks.cfg 23595 Downloads 22 install.log 23612 Pictures 23613 Videos
23594 Desktop 23585 fbcmd_update.php 35 install.log.syslog 23601 Public
### 11. Shows version of ls command ###
Check version of ls command.
# ls --version
ls (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Richard M. Stallman and David MacKenzie.
### 12. Show Help Page ###
List help page of ls command with their option.
# ls --help
Usage: ls [OPTION]... [FILE]...
### 13. List Directory Information ###
With ls -l command list files under directory /tmp. Wherein with -ld parameters displays information of /tmp directory.
# ls -l /tmp
total 408
drwx------. 2 narad narad 4096 Aug 2 02:00 CRX_75DAF8CB7768
-r--------. 1 root root 384683 Aug 4 12:28 htop-1.0.1.tar.gz
drwx------. 2 root root 4096 Aug 4 11:20 keyring-6Mfjnk
drwx------. 2 root root 4096 Aug 16 01:33 keyring-pioZJr
drwx------. 2 gdm gdm 4096 Aug 21 11:26 orbit-gdm
drwx------. 2 root root 4096 Aug 19 08:41 pulse-gl6o4ZdxQVrX
drwx------. 2 narad narad 4096 Aug 4 08:16 pulse-UDH76ExwUVoU
drwx------. 2 gdm gdm 4096 Aug 21 11:26 pulse-wJtcweUCtvhn
-rw-------. 1 root root 300 Aug 16 03:34 yum_save_tx-2012-08-16-03-34LJTAa1.yumtx
----------
# ls -ld /tmp/
drwxrwxrwt. 13 root root 4096 Aug 21 12:48 /tmp/
### 14. Display UID and GID of Files ###
To display UID and GID of files and directories. use option -n with ls command.
# ls -n
total 36
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Downloads
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Music
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Pictures
-rw-rw-r--. 1 500 500 12 Aug 21 13:06 tmp.txt
drwxr-xr-x. 2 500 500 4096 Aug 2 01:52 Videos
### 15. ls command and its Aliases ###
We have made alias for ls command, when we execute ls command itll take -l option by default and display long listing as mentioned earlier.
# alias ls="ls -l"
Note: We can see number of alias available in your system with below alias command and same can be unalias as shown below example.
# alias
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
To remove an alias previously defined, just use the unalias command.
# unalias ls
In our next article well cover up more or advanced ls command with their examples. If weve missed anything in the list, please update us via comment section.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/15-basic-ls-command-examples-in-linux/
作者:[Ravi Saive][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/admin/

View File

@ -0,0 +1,187 @@
15 Interview Questions on Linux “ls” Command Part 1
================================================================================
The listing command in UNIX and UNIX like operating System ls is one of the most basic and widely used utility in command-line. It is POSIX compliant utility available for GNU coreutils and BSD variants. The ls command can be used with a variety of options to get desired results. This article aims at deep insight of file listing command in Linux with relevant examples.
![15 ls Command Questions](http://www.tecmint.com/wp-content/uploads/2014/09/ls-Command-Questions.png)
15 ls Command Questions
### 1. How will you List files from a directory? ###
Ans: The Linux file listing command ls comes to rescue here.
# ls
![List Files](http://www.tecmint.com/wp-content/uploads/2014/09/list-files.gif)
List Files
Alternatively, we can use echo command to list files within a directory in association with wildcard (*).
# echo *
![List All Files](http://www.tecmint.com/wp-content/uploads/2014/09/list-all-files.gif)
List All Files
### 2. How will you list all the directories only using echo command? ###
# echo */
![List All Directories](http://www.tecmint.com/wp-content/uploads/2014/09/list-all-directories.gif)
List All Directories
### 3. How will you list all the files within a directory including hidden files aka (.) dot files? ###
Ans: We need to use option -a (list hidden files) with command ls.
# ls -a
![List All Hidden Files](http://www.tecmint.com/wp-content/uploads/2014/09/list-all-hidden-files.gif)
List All Hidden Files
### 4. How do you list all the files within a directory including hidden files, but do not list implied . and ..? ###
Ans: We need to use option -A (do not list implied . and ..) with command ls.
# ls -A
![Do Not List Implied](http://www.tecmint.com/wp-content/uploads/2014/09/Do-not-list-Implied.gif)
Do Not List Implied
### 5. How will you print the content of a directory in long format listing? ###
Ans: We need to use option l (long format) with command ls.
# ls -l
![List Files Long](http://www.tecmint.com/wp-content/uploads/2014/09/list-files-long.gif)
List Files Long
In the above example, the output seems like.
drwxr-xr-x 5 avi tecmint 4096 Sep 30 11:31 Binary
Here, drwxr-xr-x is file permission for owner, group and world. Owner has Read(r), Write(w) and Execute(x) permission. The group to which this file belongs has Read(r) and Execute(x) permission but not Write(w) permission, same permission implies for the world that have access to this file.
- The Initial d means its a Directory.
- Number 5 represents Symbolic Link.
- The File Binary belongs to user avi and group tecmint.
- Sep 30 11:31 represents the date and time it was last modified.
### 6. You are supposed to print the content of directory in long format listing, showing hidden/dot files. How will you achieve this? ###
Ans: We need to use option -a (list hidden files) and -l (long listing) together with command ls.
# ls -la
![Print Content of Directory](http://www.tecmint.com/wp-content/uploads/2014/09/Print-Content-of-Directory.gif)
Print Content of Directory
Alternatively We can use option -A and -l with ls command, if we do not want to list implied . and ...
# ls -lA
### 7. How will you figure out the author of each file? ###
Ans: We need to use option author along with option -l to print the author name of each file.
# ls --author -l
![List Author Files](http://www.tecmint.com/wp-content/uploads/2014/09/List-Author-Files.gif)
List Author Files
### 8. How will you print escape for non-graphic character? ###
Ans: We just need to use option -b to print escape for non-graphic character.
# ls -b
![Print Escape Character](http://www.tecmint.com/wp-content/uploads/2014/09/Print-Escape-Character.gif)
### 9. List the size of files and folders in desired scale format. How will you achieve this? ###
Ans: Here option block-size=scale along with option -l needs to be used. We need to remove scale in the example with the desired scale viz M, K, etc.
# ls --block-size=M -l
# ls --block-size=K -l
![List File Scale Format](http://www.tecmint.com/wp-content/uploads/2014/09/List-File-Scale-Format.gif)
List File Scale Format
### 10. List the files within a directory, but dont show the backup files, i.e., those files that end with ~. ###
Ans: Here option -B (do not list implied entries ending with ~) comes to rescue.
# ls -B
![List File Without Backup](http://www.tecmint.com/wp-content/uploads/2014/09/List-File-Without-Backup.gif)
List File Without Backup
### 11. Sort all the files within a directory by name and show associated last modification information. ###
Ans: We need to use option -c and option -l with command ls to fulfil the need as suggested above.
# ls -cl
![Sort Files](http://www.tecmint.com/wp-content/uploads/2014/09/Sort-Files.gif)
Sort Files
### 12. Sort all the files within a directory by modification time and show associated information. ###
Ans: We need to use three options together i.e., -l, -t and -c with command ls to sort files by modification time, newest first.
# ls -ltc
![Sort Files by Modification](http://www.tecmint.com/wp-content/uploads/2014/09/Sort-Files-by-Modification.gif)
Sort Files by Modification
### 13. How will you control the output of ls command to be colorful or no-color? ###
Ans: We need to use option color=parameter. The parameter to be used with color option are auto, always and never which are self explanatory.
# ls --color=never
# ls --color=auto
# ls --color=always
![ls Colorful Output](http://www.tecmint.com/wp-content/uploads/2014/09/ls-colorful-output.gif)
ls Colorful Output
### 14. You are supposed to list directory entries themselves, not their contents. What will you do? ###
Ans: Here the option -d comes handy.
# ls -d
![List Directory Entries](http://www.tecmint.com/wp-content/uploads/2014/09/List-Directory-Entries.gif)
List Directory Entries
### 15. Create an alias for long format listing “ls -l” as “ll” and output the result to a file and not standard output. ###
Ans: Here in the above scenario, we need to add alias to .bashrc file and then use redirect operator to write the output to file and not standard output. We will be using editor nano.
# ls -a
# nano .bashrc
# ll >> ll.txt
# nano ll.txt
![Create Alias for ls command](http://www.tecmint.com/wp-content/uploads/2014/09/Create-ls-Alias.gif)
Create Alias for ls command
Thats all for now. Dont forget to provide us with your valuable feedback in the comments below. Ill be here again with another interesting article soon. Till then stay tuned and connected.
### Real Also: ###
- [10 ls Command Interview Questions Part 2][1]
- [15 Basic ls Commands in Linux][2]
--------------------------------------------------------------------------------
via: http://www.tecmint.com/ls-command-interview-questions/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/
[1]:http://www.tecmint.com/ls-interview-questions/
[2]:http://www.tecmint.com/15-basic-ls-command-examples-in-linux/