I started writing this post, in order, to help with the basic commands of linux, but I think the basic is a lot. So I’ll divide by categories it will first:
Manipulating files and folders
I intend to describe in this post, the commands that I believe to be the most useful in handling files for anyone who is starting on linux , with some parameters to make life easier. Anyone who thinks any more is needed, says, I add that in the post.
Listing files
using the command ls can list the files and folders ordered by modification date, by size, among others. We can also list only files, only folders or include links. Anyway, for more details see the documentation. man ls
Listing txt files, sorted by size
* ls-lhs. Txt
Listing png files, sorted by size in reverse order
* ls-lhSr. Png
Listing php files, sorted by modification date, in reverse order
ls-ltr *. Php
Creating Files
There are several ways to create files in linux, including:
Touch
touch test.php
Cat
cat> test.php
Using editor
You use your editor too, I like to use the nano , or peak as editor
nano test.php
peak test.php
Delete Files
Deleting files is easy, easy. Just use the command rm .
rm test.php
Deleting files for an extension
rm *. php
rm *. txt
Deleting files without confirming
Using the-f argument, force will force the removal of the file.
rm-f test.php
Creating folder
As easy as the others, just use the command mkdir .
mkdir viniciusmuniz
mkdir /var/www/viniciusmuniz
Creating folder with permission
Who ever heard of linux, ever heard the phrase “Linux has no viruses”. Well in my opnion .. a lie, but most of the reason is due to permissions management, linux will not describe it deeply, it will be another post in this series. Who uses a host with suPHP, must have seen a lot 500 internal server error . This occurs because the folder must have permission 755, and files 644 permission. To create a folder with permission, just use the option -m .
mkdir-m 0755 viniciusmuniz
Create a folder recursively
did not like the name of this item, if anyone has any better, please comment. If you want to create a folder inside another that does not exist yet, you can create everything straight.
mkdir-p /home/vinicius/test/viniciusmuniz/public_html
Removing folders
If you tried to remove a folder, you should have seen the error rm: can not remove “folder name”: is a directory . Simple to remove a folder, you have to remove it recursively. For this we will use the argument -r .
rm-r /home/vinicius/test/viniciusmuniz/public_html
Remove folder without confirmation
Using the same command to “force” will add the -f
rm-rf /home/vinicius/test/
Moving files and folders
To move the command we use mv . In the example we will be moving the folder to public_html / home / vinicius
mv /home/vinicius/test/viniciusmuniz/public_html /home/vinicius/
Renaming folders and files
The linux has no specific command to rename. Mv is used.
mv index.php test.php
mv /home/vinicius/test/ /home/vinicius/test
Modify permission
This item is here because it is directly related to this manipulation, but will again be discussed in more detail in a future post. Permission to change something, would use the chmod command.
chmod 777 /home/vinicius/test
recursively Permission
to give permission recursively , just add the option -r
chmod-R 777
Recent Comments