0% found this document useful (0 votes)
29 views3 pages

Lap 1 Directory and Files Mangment

Directory and file management

Uploaded by

mtv.maxamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Lap 1 Directory and Files Mangment

Directory and file management

Uploaded by

mtv.maxamed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Linux Programming LAP 1

1. Whoami
[root@localhost ~]# whoami // to know the current user just write whoami
2. ls command
[root@localhost ~]# ls // list show contents in your directory
3. ls -a command
[root@localhost ~]# ls -a // show your files so hidden files in your system directory

4. cd command
[root@localhost ~]# cd Music // this command used for navigation between directories”

5. home directory
[root@localhost ~]# cd /home // show you home directory, where all the users has stored e.g Mahdi
[root@localhost home]# ls

7. Creating & Viewing Files, and write something inside


[rooot@localhost ~]# cd Desktop/
[rooot@localhost ~]# / Desktop $ touch myfile // create file
[root@localhost Desktop]# cat >myfile // there is another way u can create a file but this command will give
add contents the file
[rooot@localhost Desktop]# cat myfile // print out what we have wrote the myfile

anoher example. Compound two files in one file by using cat command
[rooot@localhost ~]# cd Desktop
[rooot@localhost Desktop]# cat >mahdi1
I wana to be network administrate
[rooot@localhost Desktop]# cat >mahdi2
The quick brown fox jumps over the lazy dog
The quick brown fox jumps over the lazy dog
[rooot@localhost Desktop]# cat mahdi1 mahdi2 >elmi // we assigned elmi, the files mahdi1 and 2

8. Copy file to Director same location


[root@localhost ~ ]# cd Desktop/
[root@localhost Desktop] # cp powerpoint Eelo // copy file PowerPoint to eelo directory

9. Creating directories
[rooot@localhost ~ ]# cd Desktop/
[rooot@localhost Desktop]# mkdir Eelo //create a directory called Eelo
[rooot@localhost Desktop]# ls // check it that the directory we have been created on the desktop or not

10. Create directory and remove


Mahdi123@ubuntu:~ $ cd Music/
Mahdi123@ubuntu:~ /Music $ mkdir osman // creating a directory in the music
Mahdi123@ubuntu:~ /Music $ rmdir osman // remove a directory called osman in side the music
11. delete/remove directory when if it is NOT empty
[root@localhost Desktop]# mkdir Mahdi
[root@localhost Desktop]#cd Mahdi
[root@localhost Mahdi]# touch Eelo
[root@localhost Mahdi]# cd ..
[root@localhost Desktop]# rm –r Mahdi

12. Copy the file from Desktop to Documents by using absolute path
[root@localhost~ ]# cd Desktop
[root@localhost Desktop]# cp /root/Desktop/lap /root/Documents/ // copy file from Desk.. to Docu…

13.copy the Directory from Desktop to Documents


[root@localhost Desktop]# cp –R /root/Desktop/lap /root/Documents/ // copy directory from D.. to Documents
[root@localhost Desktop]#cd
[root@localhost Desktop]#cd Documents
[root@localhost Documents]# ls

12. Copy the File/directory form Desktop to Music by using relative path
[root@localhost Desktop]# cp oracle /root/Music // file copy by relative path
[root@localhost Desktop]# cp oracle -r /root/Music // copy Directory by relative path

13. Copy file/directory from the root to normal user by using absolute path
[root@localhost Music]# cp /root/Desktop/Lap /home/mobsiyeh/Documents/ // copy file from root to normal user
[root@localhost Music]# cp –r /root/Desktop/Unix /home/mobsiyeh/Documents/ // copy Directory from root to normal
user

14. Move the file to the directory // same location //


[rooot@localhost ~ ]# cd Desktop
[rooot@localhost Desktop]# mv myfile Eelo // move the file to Eelo Directory

Move the file from Desktop to Music directory


[rooot@localhost ~]# cd Desktop
[rooot@localhost Desktop]#

15. Move the file to other user


[rooot@localhost Desktop]# mv linux /home/mobsiyeh/Music // move from Desktop to Music Directory//

16. Move the file/directory to other user

17. Rename file name and directory


[rooot@localhost ~ ]# cd Videos
[rooot@localhost Videos] # touch Unix
[rooot@localhost Videos] # mv Unix Linux
[rooot@localhost Videos]# mkdir examfile
[rooot@localhost Videos]# mv examfile result

18. Remove file


[root@localhost ~ ]# cd Desktop
[root@localhost Desktop]# rm file1 // remove the file1 from the desktop

19. pwd - print working directory, is a Linux command to get the current working directory.
[root@localhost Desktop]# pwd
/root/Desktop

20. clear

You might also like