Learn the Linux command line - Chapter 2



cat - type  cat
Then type a few words on the keyboard and press the [Return] Or [Enter] key.
Finally hold the [Ctrl] key down and press [d] (written as ^D for short) to end the input.
Now what happend?
If wiill copy your data to the next line

cat > test.txt - To add new file and add the content into file
Write that command press enter cat > test.txt
enter your keyword like: apple, pear, banana
press Ctrl+D and now read the file by cat test.txt
If file is already created then it overwrite the file content

cat >> test.txt -
To Append the content into a existing file

cat list1.txt list2.txt > biglist.txt -  This command will copy the text from both file and create new file with the name of biglist.txt and paste the content in this file
We use the < symbol to redirect the input of a command.
The command sort alphabetically or numerically sorts a list. Type
% sort
Then type in the names of some animals. Press [Return] after each one.
dog
cat
bird
ape
^D (control d to stop)
The output will be
ape
bird
cat
dog
Using < you can redirect the input to come from a file rather than the keyboard. For example, to sort the list of fruit, type
% sort < biglist
and the sorted list will be output to the screen.
To output the sorted list to a file, type,
% sort < biglist > slist
Read the content from biglist file and sort the content and place the content on slist
Use cat to read the contents of the file slist


ls - is use for listing the files and directory

ls *txt
- is use for listing the file which end keyword are .txt


ls linu*
- it will show all file name which start from linu keyword


ls ?list - The character ? will match exactly one character.


So ?ouse will match files like house and mouse, but not grouse.
Try typing % ls ?list


On-line command manuals
This is the main and most usable command in linux


man ls
Alternatively
whatis ls

If you will run these command then it will tell you that which command is this and how its work.
You can say that it is a manual for command line

Apropos your_command - If you forgot the command keyword and you know any word of char of the command the if will show you relative command acording to your keyword
like: apropos copy


Changing access rights

chmod (changing a file mode):
Symbol
Meaning
u
user
g
group
o
other
a
all
r
read
w
write (and delete)
x
execute (and access directory)
+
add permission
-
take away permission
we use + to give permission for file
- to take away permission from a user of a file
example: chmod go-rwx biglist
so here we are taking permission from a group user and other that they can not read,write and execute the biglist file
Example: chmod a+rw biglist
Now we are giving permission to all user to read and write the file of biglist

ls -l         =>  You can check the permission of file via this command

Comments