Birmingham mumbai



Download 15,21 Mb.
Pdf ko'rish
bet166/482
Sana13.01.2022
Hajmi15,21 Mb.
#355107
1   ...   162   163   164   165   166   167   168   169   ...   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)

[
 119 
]
In that example, we removed the target path and name, and replaced it with a 
period. The reason this works is that the period represents our current working 
directory. This isn't specific to the 
cp
 command either. There actually is a directory 
named with a period in every directory, which is essentially a pointer to the current 
directory. Therefore, if you're already inside the directory where you want the file to 
be copied to, you don't have to type the path. You don't have to type the name either, 
if you want the name of the file to be the same as the source.
Copying files (as well as moving them, which we'll look at next) is potentially 
destructive. If the target path and name already exist, then the target will be 
overwritten. By default, you won't see a confirmation before the target file is 
overwritten. As with all commands, take care that you really want to do whatever it 
is you're telling the command-line interpreter to do.
When it comes to copying directories, the 
cp
 command by itself won't do the trick:
sudo cp /var/log/apt .
The 
/var/log/apt
 directory contains log files that keep track of transactions 
performed with the 
apt
 command. It can be useful to keep an eye on what your other 
admins are installing. When it comes to this example though, the previous command 
will fail with the following error:
cp: -r not specified; omitting directory '/var/log/apt'
The error literally tells you what to do about it, but essentially the error is telling 
you that directories are omitted by default. In order to copy directories, you'll need 
to include the 
-r
 option. This stands for 
recursive
, which is an option you'll see as a 
possibility for a handful of Linux commands. It tells the command-line interpreter 
to not only grab the object at the path you specified, but to do so recursively and 
include child objects as well. Therefore, the following command will work:
sudo cp -r /var/log/apt .
With that command, a local copy of the 
/var/log/apt
 directory will be stored in your 
current working directory, along with the contents.
When it comes to moving a file or directory from one place to another, we use the 
mv
 
command. The syntax is almost exactly the same as the 
cp
 command. The difference 
is that instead of copying a file or directory, we're moving it. In that regard, it's 
probably self-explanatory how it works. Consider the following example commands:
mv file1 /path/to/new/directory/file1
mv file1 file2


Managing Files and Directories

Download 15,21 Mb.

Do'stlaringiz bilan baham:
1   ...   162   163   164   165   166   167   168   169   ...   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