• cp — copying files on the server
  • mv — 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 to copy and the mv command is used to move. 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 —

viewing 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 (date of creation, size,..)
  • ls -l dir/ — get a list of files and directories in the dir subdirectory with details

cd command - 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 the catalog to a higher level
  • cd /home/u12345/domain.ru/www/ — go to the directory /home/u12345/domain.ru/www/

The pwd command is to determine 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;
  • chmod 000 www/file.html —change the access mode for the file file.html in the www directory to 000. With this access mode, no one will be able to open it. This way you can quickly deny access to a certain file via the web.

The rm command removes files or directories.

The rm command is used to remove files or directories. By default, directories are not deleted. In order to delete a directory along with its contents, use the -r switch.

Examples:

  • rm index.php — delete the index.php file (the file is located in the current directory);
  • rm -r cache — delete cache directory;
  • rm /home/u12345/domain.tld/www/index.php — delete the index.php file (the full path to the file is specified).
Was this answer helpful? 26 Users Found This Useful (85 Votes)