Меню Рубрики

Create folder linux terminal

How to create a new folder from a terminal with administrative permissions?

I want to install JAVA, but the installation instructions ask me to create a new folder, called /java/ , into the standard /usr/ folder.

But this folder is blocked. I mean, I can not to create a new folder on it, with the PCManFM file manager, because that option is grey.

So I guess there should be a command to create it from a Terminal session. (With sudo , maybe?)

How can I get it? Which is the right command to get it?

4 Answers 4

I’m going to address two parts of your question: java installation and folder creation.

Java installation

We already have a question about that: How can I install Sun/Oracle’s proprietary Java JDK 6/7/8 or JRE?.All of the necessary commands are there, and I strongly suggest you read their manual pages with man COMMAND in terminal.

There’s also open-source version of Java, Open JDK. Installation of that is somewhat simpler

That’s pretty much it — apt-get will take care of everything. When you install some package with apt-get or dpkg there should be preinstall and postinstall scripts that come along with the package, and run automatically to set up whatever program you’re getting.

Folder Creation

Folder ( in linux terminology — directory ) creation, just like file creation, depends on the permissions. If a folder has the following permissions,

that means the owner of that folder testuser can read-write-execute stuff there (first rwx ), and group testuser can only read and execute stuff there — that’s the r-x part, and final r-x part means read execute for any other groups or users.

/usr folder is owned by root user, so only root can write there, that means create files or folder. Hence for that you need sudo to gain root privileges temporarily.

Источник

How to Use ‘mkdir’ to Create Linux Directories

Make folders from a terminal with this simple command

What to Know

  • To create directories in Linux, you can open Terminal and use the command line with the mkdir command.
  • Once you create a new directory in Linux, then you can change permissions and create folders within the directory.
  • You can also create a directory and set permissions at the same time.

You can create new directories in Linux using the command line. The command to create directories is mkdir. Here is how to create directories with mkdir.

This article also looks at the switches used with mkdir and the proper syntax required to make the command work correctly.

How to Create a New Directory

The simplest way to create a new directory is to enter the following command:

For example, to create a directory called test, open a terminal window, navigate to the folder where you want the new folder, then enter:

Change the Permissions of the New Directory

After creating a new folder, set the permissions so that only a certain user can access it or so that some people can edit files in the folder, but others have read-only permissions.

To continue with the example above, run the ls command to see the permissions for the folder called test:

Run the ls command in the folder where the test folder is located. If it’s your home directory (for example, you didn’t use the cd command), then you don’t have to change the directory here.

You should see something like this (but probably with several other entries, considering that there are other folders there):

The permissions are drwxrwxr-x, 2, owner, and group.

    • The d indicates that test is a directory.
      The first three letters following the d are the owner permissions for the directory specified by the owner’s name:
      r is for read.
    • w is for write.
    • x is for execute (which means you can access the folder).
  • The next three characters are the group permissions for the file specified by the group name. The options are r, w, and x. The hyphen means that a permission is missing. In the example above, anybody belonging to the group can access the folder and see the files, but can’t write to the folder.
  • The final characters are the permissions that all users have, and these are the same as the group permissions.

To change the permissions for a file or folder, use the chmod command. The chmod command lets you specify three numbers which set the permissions:

Add the numbers together for a mixture of permissions. For example, to attribute read and execute permissions, the number is 5 (4+1), or for read and write permissions, the number is 6 (4+2).

You must specify three numbers as part of the chmod command. The first number is for the owner permissions, the second is for the group permissions, and the last is for everyone else.

For example, for the owner to have full permissions, the group to have read and execute permissions, and anyone else to have no permissions, enter the following:

Use the chgrp command to change the group name that owns a folder. For example, to create a directory that the accountants in a company can access, first make the group accounts by typing the following:

If you don’t have the correct permission to create a group, use sudo to gain extra privileges or use the su command to switch to an account with valid permissions.

Next, change the group for a folder by typing the following:

To give the owner and everybody else in the accounts group read, write, and execute, but read-only access to others, use the following command:

How to Create a Directory and Set Permissions at the Same Time

You can create a directory and set the permissions for that directory at the same time using the following command:

This command creates a folder that everybody can access. It’s rare to create folders with this kind of permission.

Create a Folder and Any Parents That Are Required

You can create a directory structure without creating each individual folder, for example, to create folders for music as follows:

  • /home/music/rock/alicecooper
  • /home/music/rock/queen
  • /home/music/rap/drdre
  • /home/music/jazz/louisjordan

It takes time to create the rock folder for alice cooper and queen, followed by the rap and jazz folders for the others.

By specifying -p, you can create all the parent folders on the fly if these don’t exist:

For example, this mkdir command makes one of the folders listed above:

Get Confirmation That a Directory Was Created

By default, the mkdir command doesn’t tell you if the directory was created successfully. Usually, if no errors are shown, you can assume it worked. However, if you want more verbose output so that you know what’s been created, use the -v switch:

Источник

Как создать папку Ubuntu

Эта статья ориентированна на самых начинающих. Для тех кто только-только начал разбираться с операционной системой Ubuntu. Хранить файлы все свои файлы в одной папке очень неудобно, а стандартных папок со временем начнет не хватать. Кроме того, может понадобится создать папку для временных файлов или какой-нибудь программы. Сегодня мы рассмотрим как создать папку в Ubuntu. Мы поговорим о том как создать папку linux с помощью файлового менеджера, а также рассмотрим различные способы создания папки в терминале.

Способ 1 Файловый менеджер

Сначала нужно открыть файловый менеджер Nautilus. Для этого кликните по его ярлыку на панели Unity или в меню Dash:

Дальше перейдите в каталог, в котором вы хотите создать новую папку:

Создать папку Ubuntu можно в контекстном меню. Просто кликните правой кнопкой мыши по свободной области файлового менеджера для вызова меню. Затем выберите пункт «создать папку»:

Теперь осталось указать имя папки. Оно может содержать любые буквы, цифры, а также все символы, кроме косой черты. Linux в этом плане отличается от Windows и вы можете назвать свою папку как захотите, без ограничений:

Чтобы сохранить изменения еще раз кликните в свободном месте файлового менеджера.

Способ 2. Терминал

Новички, как правило, не хотят пользоваться терминалом, считают его слишком сложным. Но с чего-то же надо начинать, поэтому здесь мы рассмотрим как создать папку через терминал Ubuntu.

Создание папок в Linux выполняется с помощью замечательной утилиты — mkdir. Все что она может — это создавать папки. Рассмотрим ее синтаксис:

$ mkdir опции имя_папки

Опций в утилиты не так много, а передавать программе вы чаще всего будете только один параметр — имя папки

Давайте попробуем. Откройте терминал (Нажмите сочетание клавиш Ctrl+Alt+T) и наберите следующую команду:

В текущей директории будет создана папка с указанным именем. Если нужно создать папку в другой директории, перед именем укажите путь к той директории:

Утилита создаст папку в подпапке загрузки. Можно использовать не только путь относительно текущей папки, но и указать полный путь в файловой системе:

Это собственно все основное. Но еще я хочу вам показать на что способен терминал в отличие от графических программ.

Например, нам нужно создать несколько папок, тогда можно сделать все одной командой:

Если нужно создать папку Ubuntu, а в ней еще несколько папок, можно воспользоваться командой:

Или, например, сложная структура:

Выводы

В этой статье я рассказал как создать папку в Ubuntu. Это очень просто. К тому же, как вы увидели, все можно делать намного эффективнее с помощью консольных команд.

Десерт на сегодня — птичка, которая отлично имитирует звуки из Звездных войн:

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Gpu driver mac os
  • Gpt диск mac os
  • Gpt в mbr mac os
  • Gpg4usb mac os x
  • Gothic 2 mac os