Useful Linux Commands Print

  • 1

cp command - copying files on the server
mv command - moving files on the server
The Unix shell on our server can be used by you as a convenient tool for copying or moving files. The cp command is used for copying, and the mv command is used for moving. The cp command also has the -r switch (fully cp -r), which allows you to copy not only files, but also subdirectories with files.

Examples:

cp old/*.html new/ - copy all files with *.html extension from the old directory to the new directory
cp -r old/* new/ - copy all files and subdirectories from the old directory to the new directory
mv old/* new/ - move (copy and delete in the old place) all the contents of the old directory to the new directory
ls command - view a list of files on the server

The ls command is used to obtain a list of files that are currently hosted on a Unix server.

Examples:

ls - shows a list of files in the current directory
ls -l - list of files with details (creation date, size,..)
ls -l dir/ - get a list of files and directories in the dir subdirectory with details
Command cd - go to another directory

The cd command (full name is chdir) is used to move from one directory on a Unix server to another. By making this transition, you change the current directory to a new one

Examples:

cd - go to the “home directory” (where you go immediately when you log into the server)
cd .. - go to a higher level directory
cd /home/u12345/domain.ru/www/ - go to the directory /home/u12345/domain.ru/www/
The pwd command determines the current directory.

The pwd command (without parameters) allows you to determine which directory on the Unix server you are currently in. Shows the full path to the directory that is your current one. Can be used, for example, to determine the full path to the user's home directory - this is sometimes required to be specified in some Perl and PHP scripts.

The chmod command is to change the file access mode.

Sometimes you need to manually change the access mode for files on the Unix server disk. This is often necessary when placing CGI scripts on the server. You can read more about the operation of chmod and access modes in the chmod documentation. We will give examples of working with chmod under hosting conditions:

chmod 755 script.pl - change the access mode to the script.pl file to 755 (this is the access mode required for scripts);
chmod -R 755 cgi-bin/*.pl — change the access mode to 755 for all files with the *.pl extension in the cgi-bin directory and all its subdirectories;


Was this answer helpful?

« Back