Monthly Archives: December 2020

copy the contents of a folder to another folder ubuntu

Check this http://www.cyberciti.biz/faq/copy-folder-linux-command-line/ for more information on copying folder. Hope this helps.

cp Command

cp is a Linux command for copying files and directories. The syntax is as follows:

cp source destination
cp dir1 dir2
cp -option  source destination
cp -option1 -option2  source destination

In this example copy /home/vivek/letters folder and all its files to /usb/backup directory:

cp -avr /home/vivek/letters /usb/backup

Where,

-a : Preserve the specified attributes such as directory an file mode, ownership, timestamps, if possible additional attributes: context, links, xattr, all.

-v : Explain what is being done.

-r : Copy directories recursively. Example

Copy a folder called /tmp/conf to /tmp/backup:

$ cp -avr /tmp/conf/ /tmp/backup

How to Create a New User mysql

  1. mysql  >CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;
  2. mysql> GRANT ALL PRIVILEGES ON * . * TO ‘newuser’@’localhost’;
  3. mysql> FLUSH PRIVILEGES;

How To Grant Different User Permissions

Here is a short list of other common possible permissions that users can enjoy.

  • ALL PRIVILEGES- as we saw previously, this would allow a MySQL user full access to a designated database (or if no database is selected, global access across the system)
  • CREATE- allows them to create new tables or databases
  • DROP- allows them to them to delete tables or databases
  • DELETE- allows them to delete rows from tables
  • INSERT- allows them to insert rows into tables
  • SELECT- allows them to use the SELECT command to read through databases
  • UPDATE- allow them to update table rows
  • GRANT OPTION- allows them to grant or remove other users’ privileges

To provide a specific user with a permission, you can use this framework:

mysql> GRANT type_of_permission ON database_name.table_name TO ‘username’@’localhost’;

If you want to give them access to any database or to any table, make sure to put an asterisk (*) in the place of the database name or table name.

Each time you update or change a permission be sure to use the Flush Privileges command.

If you need to revoke a permission, the structure is almost identical to granting it:

mysql> REVOKE type_of_permission ON database_name.table_name FROM ‘username’@’localhost’;

Note that when revoking permissions, the syntax requires that you use FROM, instead of TO as we used when granting permissions.

You can review a user’s current permissions by running the following:

mysql> SHOW GRANTS FOR ‘username’@’localhost’;

Just as you can delete databases with DROP, you can use DROP to delete a user altogether:

mysql> DROP USER ‘username’@’localhost’;

To test out your new user, log out by typing:

mysql> quit

Create a New User and Grant Permissions in MySQL

In Part 1 of the MySQL Tutorial, we did all of the editing in MySQL as the root user, with full access to all of the databases. However, in cases where more restrictions may be required, there are ways to create users with custom permissions.

Let’s start by making a new user within the MySQL shell:

 

mysql> CREATE USER ‘newuser’@’localhost’ IDENTIFIED BY ‘password’;

mysql>RANT ALL PRIVILEGES ON * . * TO newuser@‘localhost’;

mysql>FLUSH PRIVILEGES;