Читать книгу Kali Linux Penetration Testing Bible - Gus Khawaja - Страница 29

Manipulating Files in Kali

Оглавление

To simply create an empty file in Linux, you can use the touch command:

$touch [new file]

To insert text quickly into a file, you can use the echo command. Later in this chapter, you will learn how to edit text files with a text editor:

$echo 'text to add'> [file name]

To know a file type in a Linux system, you must use the file command:

$file [file name]

Let's assemble all the commands together in the terminal window:

root@kali:~# touch test.txt root@kali:~# echo test> test.txt root@kali:~# file test.txt test.txt: ASCII text

To copy a file in Kali, you must use the cp command to get the job done:

$ cp [source file path] [destination file path] root@kali:~# cp test.txt /home/kali root@kali:~# ls /home/kali Desktop Downloads Music Public test.sh Videos Documents ls_file.txt Pictures Templates test.txt

To move a file that is equivalent to cut in Windows OS, you must use the mv command:

$mv [source file path] [destination file path] root@kali:~# mv test.txt Documents/ root@kali:~# ls Documents/ test.txt

To delete the file that we just copied earlier in the kali home directory, use the rm command:

$rm [file path – that you want to delete] root@kali:~# rm /home/kali/test.txt

To rename the previous file, we use the same mv command that we used to move a file:

$mv [original file name] [new file name] root@kali:~/Documents# mv test.txt hello.txt root@kali:~/Documents# ls hello.txt

Kali Linux Penetration Testing Bible

Подняться наверх