Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet165/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   161   162   163   164   165   166   167   168   ...   482
Bog'liq
Mastering Ubuntu Server Gain expertise in the art of deploying, configuring, managing, and troubleshooting Ubuntu Server by Jay LaCroix (z-lib.org)

[
 118 
]
Copying, moving, and renaming files 
and directories
At this point, you should know how to 
move around within the filesystem 
(commands such as 
cd
), inspect the contents of directories (
ls
), and even how to 
create empty files (the 
touch
 command). We even know how to remove files as well, 
such as executing the 
rm
 command against a file or directory. But until now, we 
haven't looked at moving files around within your Ubuntu filesystem.
First, to make a copy of a file or directory, we use the 
cp
 command. Copying a file is 
fairly easy, and such a command would look similar to the following:
cp file1 file2
In that example, 
file2
 is created as an exact copy of 
file1
. Copying a file is useful in 
many situations, some of the most common of which are:
• 
Copying a file to a backup medium, such as an external drive or network 
share
• 
Creating a copy of a file before making a change, such as before editing a 
very important text file
• 
Duplicating a log file for a point-in-time analysis
Let's look at the last bullet point as another good example. We can capture a copy 
of the system log and store it in our current working directory by executing the 
following command:
sudo cp /var/log/syslog /home//syslog
The 
cp
 command is fairly simple: we give it a path to a file to copy, and then we 
type the path to the destination and desired filename. We also use 
sudo
 due to the 
fact that the 
syslog
 file 
is not readable by normal users by default. In the case of this 
command, a copy of the original 
syslog
 file will be saved in your current working 
directory.
For this particular example, log files are constantly being written to. It can sometimes 
be hard to troubleshoot an issue that occurred during a certain time if the file is 
continually expanding. That's not the only reason though. We certainly wouldn't 
want to make an accidental change to the log file and risk contaminating it or losing 
important information.
The previous command can actually be simplified a bit:
sudo cp /var/log/syslog .


Chapter 5

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   161   162   163   164   165   166   167   168   ...   482




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish