mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-12 01:40:10 +08:00
20131119-2 选题
This commit is contained in:
parent
481a5d6991
commit
fca8d1fd6d
234
sources/10 Lesser Known Commands for Linux – Part 3.md
Normal file
234
sources/10 Lesser Known Commands for Linux – Part 3.md
Normal file
@ -0,0 +1,234 @@
|
||||
10 Lesser Known Commands for Linux – Part 3
|
||||
================================================================================
|
||||

|
||||
|
||||
We have come up with the third article of this series which includes few other lesser known Linux commands, worth knowing. May be you are already aware of these commands, no doubt you are an experienced Linux user and loves exploration.
|
||||
|
||||
### 22. ^foo^bar Command ###
|
||||
|
||||
Run the last command with modification, in a single instance. Suppose I need to run a command ‘**ls -l**‘ to long list the content of a directory say ‘**Desktop**’. Accidentally, you type ‘**lls -l**‘. So now you will have to retype the whole command or edit the previous command using navigation key. That is painful when the command is long.
|
||||
|
||||
avi@localhost:~/Desktop$ lls -l
|
||||
bash: lls: command not found
|
||||
|
||||
|
||||
avi@localhost:~/Desktop$ ^lls^ls
|
||||
|
||||
ls -l
|
||||
total 7489440
|
||||
|
||||
drwxr-xr-x 2 avi avi 36864 Nov 13 2012 101MSDCF
|
||||
-rw-r--r-- 1 avi avi 206833 Nov 5 15:27 1.jpg
|
||||
-rw-r--r-- 1 avi avi 158951 Nov 5 15:27 2.jpg
|
||||
-rw-r--r-- 1 avi avi 90624 Nov 5 12:59 Untitled 1.doc
|
||||
|
||||
**Note**: In the above replacement we used “**^typo(to be replaced)^original_command**”. This command may be very dangerous if you knowingly or unknowingly replaced the typo with system command or anything risky say **rm -rf**.
|
||||
|
||||
### 23. > file.txt Command ###
|
||||
|
||||
This command flush the contents of a file without the need of removing and creating the same file again. This command is very useful in scripting language when we need an output or log on the same file again and again.
|
||||
|
||||
I have a file say ‘**test.txt**’ on my ‘**Desktop**‘ with a lot of text.
|
||||
|
||||
avi@localhost:~/Desktop$ cat test.txt
|
||||
|
||||
Linux
|
||||
GNU
|
||||
Debian
|
||||
Fedora
|
||||
kali
|
||||
ubuntu
|
||||
git
|
||||
Linus
|
||||
Torvalds
|
||||
|
||||
|
||||
avi@localhost:~/Desktop$ > test.txt
|
||||
avi@localhost:~/Desktop$ cat test.txt
|
||||
|
||||
**Note**: Again, this command can be dangerous, don’t ever try to flush the contents of a system file or configuration file. If you do so, you will be in serious trouble.
|
||||
|
||||
### 24. at Command ###
|
||||
|
||||
The ‘**at**‘ command is similar to [cron command][1] and can be used for scheduling a task or command to run at specified time.
|
||||
|
||||
avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 14:012
|
||||
|
||||
OR
|
||||
|
||||
avi@localhost:~/Desktop$ echo "ls -l > /dev/pts/0" | at 2:12 PM
|
||||
|
||||
**Sample Output**
|
||||
|
||||
-rw-r--r-- 1 avi avi 220492 Nov 1 13:49 Screenshot-1.png
|
||||
-rw-r--r-- 1 root root 358 Oct 17 10:11 sources.list
|
||||
-rw-r--r-- 1 avi avi 4695982080 Oct 10 20:29 squeeze.iso
|
||||
..
|
||||
..
|
||||
-rw-r--r-- 1 avi avi 90624 Nov 5 12:59 Untitled 1.doc
|
||||
-rw-r--r-- 1 avi avi 96206 Nov 5 12:56 Untitled 1.odt
|
||||
-rw-r--r-- 1 avi avi 9405 Nov 12 23:22 Untitled.png
|
||||
|
||||
**Note**: echo “**ls -l**” : This string echo’s the command (here **ls -l**) on standard terminal. You can replace ‘**ls -l**‘ with any command of your need and choice.
|
||||
|
||||
> : redirects the output
|
||||
|
||||
The **/dev/pts/0** : This is the output device and/or file, where output is sought, here the output is at terminal.
|
||||
|
||||
In my case, my **tty** is at **/dev/pts/0**, at that time. You can check your **tty** by running command **tty**.
|
||||
|
||||
avi@localhost:~/Desktop$ tty
|
||||
|
||||
/dev/pts/0
|
||||
|
||||
**Note**: The ‘**at**‘ command execute the task as soon as the system clock matches the specified time.
|
||||
|
||||
### 25. du -h –max-depth=1 Command ###
|
||||
|
||||
The below command outputs the size of sub-folders within the current directory, in human readable format.
|
||||
|
||||
avi@localhost:/home/avi/Desktop# du -h --max-depth=1
|
||||
|
||||
38M ./test
|
||||
1.1G ./shivji
|
||||
42M ./drupal
|
||||
6.9G ./101MSDCF
|
||||
16G .
|
||||
|
||||
**Note**: The above command can be very much useful in [checking system disk usage][2].
|
||||
|
||||
### 26. expr Command ###
|
||||
|
||||
The ‘**expr**‘ command is not that much lesser known command. This command is very much useful in carrying out simple mathematical calculation in terminal.
|
||||
|
||||
avi@localhost:/home/avi/Desktop# expr 2 + 3
|
||||
5
|
||||
|
||||
avi@localhost:/home/avi/Desktop# expr 6 – 3
|
||||
3
|
||||
|
||||
avi@localhost:/home/avi/Desktop# expr 12 / 3
|
||||
4
|
||||
|
||||
avi@localhost:/home/avi/Desktop# expr 2 \* 9
|
||||
18
|
||||
|
||||
### 27. look Command ###
|
||||
|
||||
Check for words from English dictionary in case of confusion, from the terminal itself. Viz., I am a bit confused if the spelling is carrier or carieer.
|
||||
|
||||
avi@localhost:/home/avi/Documents# look car
|
||||
|
||||
Cara
|
||||
Cara's
|
||||
…
|
||||
...
|
||||
carps
|
||||
carpus
|
||||
carpus's
|
||||
carrel
|
||||
carrel's
|
||||
carrels
|
||||
carriage
|
||||
carriage's
|
||||
carriages
|
||||
carriageway
|
||||
carriageway's
|
||||
carried
|
||||
carrier
|
||||
carrier's
|
||||
carriers
|
||||
carries
|
||||
…
|
||||
...
|
||||
caryatids
|
||||
|
||||
The above command showed all the words from dictionary starting with string ‘car’. I got what I was searching for.
|
||||
|
||||
### 28. yes Command ###
|
||||
|
||||
Another command which is not used frequently on regular basis, normally but is very useful in scripting language and for system Administrators.
|
||||
|
||||
This command continues to print a given string, till interrupt instruction is given by you.
|
||||
|
||||
avi@localhost:~/Desktop$ yes "Tecmint is one of the best site dedicated to Linux, how to"
|
||||
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
…
|
||||
…
|
||||
...
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
Tecmint is one of the best site dedicated to Linux, how to
|
||||
|
||||
### 29. factor Command ###
|
||||
|
||||
The factor command is actually a command of mathematical origin. This command outputs all the factors of a given number.
|
||||
|
||||
avi@localhost:~/Desktop$ factor 22
|
||||
22: 2 11
|
||||
|
||||
avi@localhost:~/Desktop$ factor 21
|
||||
21: 3 7
|
||||
|
||||
avi@localhost:~/Desktop$ factor 11
|
||||
11: 11
|
||||
|
||||
### 30. ping -i 60 -a IP_address ###
|
||||
|
||||
All of us use ping command to check is server is live or not. And I usually ping google, to check if I am connected to internet or not.
|
||||
|
||||
It is sometimes irritating, when you wait and keep watching your terminal to get reply of ping command or say, wait for server to get connected.
|
||||
|
||||
How about an audible sound as soon as the server comes live.
|
||||
|
||||
avi@localhost:~/Desktop$ ping -i 60 -a www.google.com
|
||||
|
||||
PING www.google.com (74.125.200.103) 56(84) bytes of data.
|
||||
64 bytes from www.google.com (74.125.200.103): icmp_req=1 ttl=44 time=105 ms
|
||||
64 bytes from 74.125.200.103: icmp_req=2 ttl=44 time=281 ms
|
||||
|
||||
Let me tell you one thing, before you report that the command didn’t return any audible sound. Make sure your system audio is not mute, sound theme must be enabled in ‘**sound preferences**‘ and make sure ‘**Enable window and window sound**‘ is checked.
|
||||
|
||||
### 31. tac Command ###
|
||||
|
||||
This command is very interesting which prints the content of a text file in **reverse order**, i.e., from last line to first line.
|
||||
|
||||
I have a text file 35.txt in my Documents directory, under home folder. Checking it’s content using [cat command][3].
|
||||
|
||||
avi@localhost:~/Documents$ cat 35.txt
|
||||
|
||||
**Sample Output**
|
||||
|
||||
> 1. Linux is built with certain powerful tools, which are unavailable in windows.
|
||||
> 2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
|
||||
> 3. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.
|
||||
|
||||
Now reverse the content of file using tac command.
|
||||
|
||||
avi@localhost:~/Documents$ tac 35.txt
|
||||
|
||||
**Sample Output**
|
||||
|
||||
> 3. Shell scripting/programming makes it possible to execute command(s), piped to get desired output in order to automate day-to-day usages.
|
||||
> 2. One of such important tool is Shell Scripting. Windows however comes with such a tool but as usual it is much weak as compared to it's Linux Counterpart.
|
||||
> 1. Linux is built with certain powerful tools, which are unavailable in windows.
|
||||
|
||||
That’s all for now. If you are aware of other lesser known Linux commands, you can put a comment, so that we can include those in our future articles.
|
||||
|
||||
Don’t forget to provide us with your value-able comment. I’ll be soon coming with another interesting article, very soon. Till then stay tuned and connected to **Tecmint**.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/10-lesser-known-commands-for-linux-part-3/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.tecmint.com/11-cron-scheduling-task-examples-in-linux/
|
||||
[2]:http://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/
|
||||
[3]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
101
sources/11 Basic Linux Interview Questions and Answers.md
Normal file
101
sources/11 Basic Linux Interview Questions and Answers.md
Normal file
@ -0,0 +1,101 @@
|
||||
11 Basic Linux Interview Questions and Answers
|
||||
================================================================================
|
||||
Theories apart, we are proud to announce a new section on Tecmint, dedicated to Linux Interview. Here we will bring to you Linux Interview Questions and all other aspects of Linux, which is must for a professional in this cut-throat competition world.
|
||||
|
||||

|
||||
|
||||
A new article in this section (**Linux Interview**) will be posted on every weekend. The initiative taken by **Tecmint** is first of it’s kind among other **Linux Dedicated** websites, along with quality and unique articles.
|
||||
|
||||
We will start with **Basic Linux Interview Question** and will go advance article by article, for which your response is highly appreciated, which put us on a higher note.
|
||||
|
||||
#### Q.1: What is the core of Linux Operating System? ####
|
||||
|
||||
- Shell
|
||||
- Kernel
|
||||
- Command
|
||||
- Script
|
||||
- Terminal
|
||||
|
||||
> **Answer** : Kernel is the core of Linux Operating System. Shell is a command Line Interpreter, Command is user Instruction to Computer, Script is collection of commands stored in a file and Terminal is a command Line Interface
|
||||
|
||||
#### Q.2: What Linus Torvalds Created? ####
|
||||
|
||||
- Fedora
|
||||
- Slackware
|
||||
- Debian
|
||||
- Gentoo
|
||||
- Linux
|
||||
|
||||
> **Answer** : Linux Torvalds created Linux, which is the kernel (heart) of all of the above Operating System and all other Linux Operating System.
|
||||
|
||||
#### Q.3: Torvalds, Wrote most of the Linux Kernel in C++ programming Language, do you agree? ####
|
||||
|
||||
> **Answer** : No! Linux Kernel contains 12,020,528 Lines of codes out of which 2,151,595 Lines are comments. So remaining 9,868,933 lines are codes and out of 9,868,933 Lines of codes 7,896,318 are written in C Programming Language.
|
||||
|
||||
The remaining Lines of code 1,972,615 is written in C++, Assembly, Perl, Shell Script, Python, Bash Script, HTML, awk, yacc, lex, sed, etc.
|
||||
|
||||
**Note** : The Number of Lines of codes varies on daily basis and an average of more than 3,509 lines are being added to Kernel.
|
||||
|
||||
#### Q.4: Linux initially was developed for intel X86 architecture but has been ported to other hardware platform than any other Operating System. Do you agree?. ####
|
||||
|
||||
> **Answer** : Yes, I do agree. Linux was written for x86 machine, and has been ported to all kind of platform. Today’s more than 90% of supercomputers are using Linux. Linux made a very promising future in mobile phone, Tablets. In-fact we are surrounded by Linux in remote controls, space science, Research, Web, Desktop Computing. The list is endless.
|
||||
|
||||
#### Q.5: Is it legal to edit Linux Kernel? ####
|
||||
|
||||
> **Answer** : Yes, Kernel is released under General Public Licence (GPL), and anyone can edit Linux Kernel to the extent permitted under GPL. Linux Kernel comes under the category of Free and Open Source Software (FOSS).
|
||||
|
||||
#### Q.6: What is the basic difference between UNIX and Linux Operating System. ####
|
||||
|
||||
> **Answer** : Linux Operating System is Free and Open Source Software, the kernel of which is created by Linus Torvalds and community. Well you can not say UNIX Operating System doesn’t comes under the category of Free and Open Source Software, BSD, is a variant of UNIX which comes under the category of FOSS. Moreover Big companies like Apple, IBM, Oracle, HP, etc. are contributing to UNIX Kernel.
|
||||
|
||||
#### Q. 7: Choose the odd one out. ####
|
||||
|
||||
- HP-UX
|
||||
- AIX
|
||||
- OSX
|
||||
- Slackware
|
||||
- Solaris
|
||||
|
||||
> **Answer** : Slackware is the odd in the above list. HP-UX, AIX, OSX, Solaris are developed by HP, IBM, APPLE, Oracle respectively and all are UNIX variant. Slackware is a Linux Operating System.
|
||||
|
||||
#### Q.8: Is Linux Operating system Virus free? ####
|
||||
|
||||
> **Answer** : No! There doesn’t exist any Operating System on this earth that is virus free. However Linux is known to have least number of Viruses, till date, yes even less than UNIX OS. Linux has had about 60-100 viruses listed till date. None of them actively spreading nowadays. A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.
|
||||
|
||||
#### Q.9: Linux is which kind of Operating System? ####
|
||||
|
||||
- Multi User
|
||||
- Multi Tasking
|
||||
- Multi Process
|
||||
- All of the above
|
||||
- None of the above
|
||||
|
||||
> **Answer** : All of the Above. Linux is an Operating System which supports Multi User, Running a Number of Processes performing different tasks simultaneously.
|
||||
|
||||
#### Q.10: Syntax of any Linux command is: ####
|
||||
|
||||
- command [options] [arguments]
|
||||
- command options [arguments]
|
||||
- command [options] [arguments]
|
||||
- command options arguments
|
||||
|
||||
> **Answer** : The correct Syntax of Linux Command is Command [options] [arguments].
|
||||
|
||||
#### Q.11: Choose the odd one out. ####
|
||||
|
||||
- Vi
|
||||
- vim
|
||||
- cd
|
||||
- nano
|
||||
|
||||
> **Answer** : The odd one in the above list is cd. Vi, vim and nano are editors which is useful in editing files, while cd command is used for changing directory.
|
||||
|
||||
That’s all for now. How much you learned for the above questions? How it helped you in your Interview? We would like to hear all these from you in our comment section. Wait till the next weekend, for new set of questions. Till then stay healthy, tuned and connected to **Tecmint**.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/basic-linux-interview-questions-and-answers/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user