یا به اصطلاح برگه تقلبی از ssh از دستوراتش همیشه دم دستمون باشه
ssh cheat sheet
- Delete an entire directory and all of its contents:
rm -r -f YourDirectory
What’s happening: rm = remove / delete -r = recursively deletes the directory and all files in it, including subdirectories -f = will not ask for confirmation before deleting- Extract a TAR.GZ File
tar -xvf yourfilename.tar.gz
What’s happening: tar – is calling the tar program -x – extract -z – it’s gzipped (so omit the z if you merely have a .tar file) -f – supplying filename on command line.- Move a directory and/or files to another location on the server:
mv directory/* html/
What’s happening: mv – move directory/* – All files/folders inside the Directory folder html/ – Location of where the files will be moved to
pwd | نمایش مسیر جاری |
ls | نمایش فهرستی از فایل ها و فولدر های مسیری که در آن هستیم |
ls -al | لیستی از فایل ها و اطلاعاتشان |
ls –alR | لیستی از فایل ها و اطلاعاتشان در تمام زیر فهرست ها |
ls -alR | more | همانند دستور قبلیه فقط وقتی صفحه پر شد منتظر میمونه تا شما با فشردن کلیدی ادامه رو فراخوانی کنید |
ls -alR > filename.txt | این هم همون دستور قبلی رو به صورت خروجی توی یک فایل ذخیره میکنه |
ls *.html | شما میتونید فایل ها رو با هر پسوندی لیست کنید مثلا اینجا html رو خواسته |
cd [directory name] | تعویض مسیر یا رفتن به یک دایرکتوری دیگه |
cd .. | با این دستور به دایرکتوری بالاتر از مسیری که هستید بر میگردید |
clear | صفحه رو پاک میکنه |
vdir | جزئیات بیشتری از فهرست فایل ها نسبت به دستور ls نمایش میده |
exit | از شل خارج میشه |
Moving, Copying and Deleting Files
mv [old filename] [new filename] | انتقال یا تغییر نام یک فایل |
cp [filename] [new filename] | کپی کردن فایل |
rm [filename] | حذف یک فایل |
rm * | این دستور تمام فایل ها و دایرکتوری های مسیر جاری رو حذف میکنه |
rm *.html | این دستور هم فایل هایی با پسوند html رو حذف میکنه |
Creating, Moving, Copying and Deleting Directories
mkdir [directory name] | ایجاد یک فولدر یا دایرکتوری |
ls -d */ | لیست تمام دایرکتوری های مسیر جاری |
cp -r [directory] [new directory] | کپی کردن یک دایرکتوری با تمام محتویات داخلش |
Searching Files and Directories
find . -name [filename] -print | جستجوی یک فایل با نام در مسیر جاری |
grep [text] [filename] | جستجوی یک متن داخل فایل ها |
File and Directory Permissions There are three levels of file permissions: read, write and execute. In addition, there are three groups to which you can assign permissions: file owner, user group and everyone. The command chmod followed by three numbers is used to change permissions. The first number is the permission for the owner, the second for the group and the third for everyone. Here are how the levels of permission translate:
0 = — | بدون حق دسترسی |
1 = –X | فقط اجرا |
2 = -W- | فقط نوشتن |
3 = -WX | نوشتن و اجرا |
4 = R– | فقط خواندن |
5 = R-X | خواندن و اجرا |
6 = RW- | خواندن و نوشتن |
7 = RWX | خواندن نوشتن و اجرا |
It is preferred that the group always have permission of 0. This prevents other users on the server from browsing files via Telnet and FTP. Here are the most common file permissions used:
chmod 604 [filename] | حداقل حق دسترسی یک فایل html |
chmod 705 [directory name] | حداقل حق دسترسی یک دایرکتوری یا فولدر |
chmod 755 [filename] | حداقل حق دسترسی به برنامه ها و اسکریپت ها |
chmod 606 [filename] | حق دسترسی به فایل های داده مورد نیاز برنامه ها |
chmod 703 [directory name] | حق دسترسی فقط نوشتن برای public_ftp |
How do I unzip a file with telnet?
All of the below commands assume that you are within the same directory that the compressed file is in. To be sure type: ls {enter} If the file is there, you’re ready to go. If not type: cd /big/dom/xdomain/www/directory/ {enter} replacing the path with the correct path to your file. If a file ends in .zip (for example, file.zip) type: unzip file.zip If a file ends in .tar (e.g., file.tar) type: tar -xvf file.tar If a file ends in .gz (for example, file.gz) type: gzip -d file.gz If a file ends in .tar.gz (e.g. file.tar.gz) type: gzip -d file.tar.gz and then tar -xvf file.tar If a file ends in .tgz (e.g. file.tgz)
|
Moving files via SSH
Often you will need to move one or more files/folders or copy them to a different location. You can do so easily using an SSH connection. The commands which you would need to use are
mv
(short for ‘move’) and cp
(short for ‘copy’).The mv command syntax looks like this:
mv configuration.php-dist configuration.php
By issuing the above command we will move (rename) the file configuration.php-dist to configuration.php.
You can also use mv to move a whole directory and its content:
mv includes/* ./
This will move all files (and folders) in the includes/ directory to the current working directory.
In some cases however, we will need to only update the files and move only files that were changed, which we can do by passing ‘-u’ as argument to the command:
mv -u includes/* admin/includes
The copy (
cp
) command works the same way as mv
, but instead of moving the files/folders it copies them. For example:cp configuration.php-dist configuration.php
The command will copy the
configuration.php-dist
file to configuration.php
and will preserve the original file (the file will NOT be removed after it is copied).cp
also accepts various arguments:cp -R includes/ includes_backup/
-R
instructs cp
to copy files recursively (for example, a whole directory). To overwrite already existing files you should use the -f
argument:cp -Rf includes/ admin/includes/
هیچ نظری موجود نیست:
ارسال یک نظر