Some Linux Commands - File and Folder Manipulation



10 Commands to manipulate the files by Eugene F. Maning :-)

1.mkdir – to create a new directory or folder.
Example:
dir
programs public_html status
mkdir hello
dir
hello programs public_html status
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2.rm – deletes a file or removes directory or folder.
Example:
dir
hello programs public_html status
rm -r hello
dir
programs public_html status
>> this deleted the folder hello with the use of the operand -r
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3.cp – copies files or folders to other directories.
Example:
dir
programs public_html status
cp -r programs public_html
cd public_html
dir
index.html programs s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
4.ln – to create hard and symbolic links.
Example:
dir
index.html programs s
ln -s index.html link
ls -l
i-rw-rw-rw- 1 maning_e maning_e 21 2010-06-18 20:29 index.html
lrwxrwxrwx 1 maning_e maning_e 10 2010-06-25 19:11 link -> index.html
drwx------ 2 maning_e maning_e 4096 2010-06-25 19:00 programs
-rw-r--r-- 1 maning_e maning_e 0 2010-06-18 19:36 s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5.mv – move a folder or a file from a location to another location and can also be used to rename files or folders.
Example:
dir
programs public_html status
mv programs “pragmas”
dir
pragmas public_html status
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
6.cd – used to navigate to other directories
Example:
maning_e@doombot:~$ dir
programs public_html status
maning_e@doombot:~$ cd public_html
maning_e@doombot:~/public_html$ cd
maning_e@doombot:~$
>> returned to the previous directory/location
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7.dir – displays the list of all the contents of the current directory
Example:
dir
pragmas public_html status
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

8.ls – displays all the contents of the current directory (basically the same with dir)
Example:
ls
pragmas public_html status
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9.touch – creates a file
Example:
dir
pragmas public_html status
touch test.txt
dir
pragmas public_html status test.txt
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10. less – read a content of a file
Example:
nano test.txt
>>type: hello ; and then hit ctrl + o, then ctrl + x
less test.txt
>> this will display hello in the terminal
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Leave a Reply