Open home directory linux

Igorkam

Ярлыки

  • С++ (3)
  • Стихи (1)
  • тонировка (1)
  • Цитаты (2)
  • ALTlinux (1)
  • Apache (2)
  • big-endian (1)
  • Blogger (1)
  • books (3)
  • books links (1)
  • Buisness (10)
  • C (1)
  • C# (5)
  • c++ (27)
  • car (8)
  • Cheat (1)
  • CSS (1)
  • DLL (1)
  • Draw (1)
  • Eclipse (2)
  • Films (1)
  • Firefox (4)
  • Flash (1)
  • GTK (2)
  • GUI (1)
  • Home server (1)
  • Hotels (1)
  • HTML (6)
  • IE (1)
  • Internet (2)
  • Java (1)
  • JavaScript (6)
  • jQuery (1)
  • KDE (1)
  • KeeTouch (1)
  • Linux (34)
  • little-endian (1)
  • Makefile (1)
  • MFC (6)
  • multi-thread (2)
  • Music (1)
  • ODBC (2)
  • OpenBox (2)
  • photo (4)
  • PHP (38)
  • programing (2)
  • proxy (1)
  • QML (37)
  • Qt (41)
  • QtCreator (2)
  • RegExp (3)
  • Shopping (12)
  • shutdown (1)
  • Soft (1)
  • Sound Card (1)
  • SQL (1)
  • SQL Server (14)
  • Subversion (1)
  • SVN (1)
  • teach (4)
  • text-editor (1)
  • Travels (1)
  • Ubuntu (38)
  • Upstart (1)
  • Vi (2)
  • VirtualBox (2)
  • Virtualization (1)
  • vkontakte.ru (1)
  • Web (2)
  • Web-Kit (5)
  • WinAPI (7)
  • Windows (4)

пятница, 10 июня 2011 г.

Linux домашняя директория

cd и домашняя директория

Если бы мы хотели переместиться в нашу домашнюю директорию, то могли бы набрать:

Без каких либо аргументов cd переместит в вашу домашнюю директорию, которая будет /root для суперпользователя, или обычно /home/username (где username — имя пользователя в системе — прим.пер.) для любого другого пользователя. Но, что если мы хотим указать файл в нашей домашней директории? Может быть мы хотим передать путь к файлу в качестве аргумента нашей программе myprog. Если файл расположен в нашей домашней директории, мы можем набрать:

Однако, использования абсолютного пути вроде этого, не всегда удобно. К счастью, мы можем использовать символ

Источник

6 Ways to Open Folders in Ubuntu 20.04 LTS

Opening folders in Ubuntu is one of the basic tasks you will perform as a regular Ubuntu user. Although there are many ways to do so, we all have our preferences in which way to opt for when accessing folders on our system.

In this article, we will explain some ways to:

  • Open a Folder In the File Manager (Nautilus)
  • Search and Open a Folder through the Dash
  • Access a folder In the command line (Terminal)
  • Open a folder in the Terminal through the File Manager
  • Open a folder in the File Manager through the command line
  • Access a Folder as Administrator from the File Manager

We have run the commands and procedures mentioned in this article on a Ubuntu 20.04 LTS system.

Open a Folder In the File Manager (Nautilus)

The latest versions of Ubuntu, like Ubuntu 20.04 LTS or Ubuntu 21.04, come with a default file manager by the name of Nautilus. This open-source file manager created for our GNOME desktops gives us a way to manage our files and folders.

You can access the Nautilus File Manager in the following ways:

1.Searching for the term ‘Nautilus’ from the system Dash:

Читайте также:  Windows home server box

2. Searching for the term Files or File Manager from the system Dash:

3. Accessing the File Manager from the Files icon in the Ubuntu Dock/Activities panel.

The File Manager opens in your Home folder by default. In Ubuntu you can open your required folder by double-clicking it, or by choosing one of the options from the right-click menu: Advertisement

  • Open
  • Open In New Tab

and,

  • Open In New Window

Search and Open a Folder through Dash

The Dash search lets you open a folder directly, rather than browsing it from the File Manager. Simply type the folder name in the Dash and the search results will display based on your criteria.

Through a simple click, you can open the relevant folder(see the path in case multiple search results show).

Open a folder In the command line (Terminal)

The Ubuntu command line, the Terminal is also a non-UI based approach to access your folders. You can open the Terminal application either through the system Dash or the Ctrl+Alt+T shortcut.

Here are some of the commands and symbols that will help you in browsing folders in the command line:

The cd or change directory command allows you to change your directory, or in other words, open a new folder. When you open the Terminal, you are in your home directory. The following command will help you in opening the folder of your choice:

In the above image, we have first listed the folders in the current directory through the ls command and then opened the Downloads folder through the cd command. The command prompt of the Terminal, by default, shows the current folder you are in.

The tilde (`) symbol

The tilde symbol represents our home directory. You can use this symbol in the cd command to move to a folder in your /home/[user]/ directory.

In the following image, I will open the snap folder from my home directory, and then directly open the Downloads folder from my home directory by using tilde:

The tilde symbol here has helped me in avoiding going back to the home folder first and then opening the Downloads folder.

The pwd command stands for print working directory. If you want to know the exact directory path you are currently in, simply use the following command to do so:

The ‘/’ symbol

The / symbol with the cd command helps you in directly opening the root folder.

The ‘..’ symbol

The ‘..’ symbol with the cd command helps you in navigating up one directory level:

The ‘-’ symbol

The ‘-’ symbol with the cd command helps you in going back to the previous folder you were in, before navigating to the current folder. You can think of this command as the ‘Previous Channel’ button on your tv remote control.

In the following example, I was in the /home/user/Downloads folder. Then I used the ‘..’ symbol to go back to my home folder. Now if I want to go back to the Downloads folder, I can use the following command to go back to the Downloads folder:

Open a folder in the Terminal through the File Manager

In order to open a folder from the File Manager to your Terminal application:

Right-click the selected folder and select Open in Terminal from the menu as follows:

Open a folder in the File Manager through the command line

If you are in the Ubuntu command line and want to open a specific folder in the UI File Manager, you can use one of the following two ways:

Читайте также:  Линукс для нетбука asus eee


or

Access a Folder as Administrator from the File Manager

While working with files and folders as a Linux Administrator, we frequently need to access and edit files and folders that require root permissions. We usually perform this task through the Ubuntu Terminal(the command line utility) using the sudo function. Here is a workaround to do the same through Nautilus Admin application.

Install Nautilus Admin

The following steps will help you in installing the Nautilus file manager to your Ubuntu system:

Open the Terminal through Ctrl+Alt+T or through the Ubuntu dash.

Run the following command as an administrator:

Enter Y when prompted about the use of additional disk space.

Nautilus Admin will be installed on your system. You can open it by entering Nautilus in your Ubuntu Dash as follows:

The file manager in your system is now Nautilus Admin.

Opening a Folder as an Administrator

Let us suppose that you need to open a folder that requires root permission. You can access the folder through the UI file manager; right-click and then select Open as Administrator from the menu.

In this example, we want to access the root folder from Other Locations. Since this folder requires root privileges, we will access it as follows:

You will be asked to provide authentication information, after which you will be able to access the contents of the folder.

By now, you must have mastered accessing your Ubuntu folders both through the command line and the UI. You are now even able to open sensitive folders as administrators in Ubuntu.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Источник

Linux directory structure: /home and /root folders

This is our 6 th post on understanding first level directories in /. Knowing these folders in detail or at least what each is meant for will help you understand Linux/Unix in whole. we already covered below directories, please have a look at those to understand them. In this post we will see two more directories ie /home and /root directory. These directories are meant for similar purpose. The /root is meant for just root user and /home is for all the remaining users.

A brief intro to /home directory in Linux/Unix

The /home directory is a place where by default all user home directories are created.

OK, what are user home directories for?

These directories are a kind of personal place(Working space) for all the users other than root. There will be a separate folder for each user in /home directory. For example if you have a user called ‘Tom’, then his default home directory is /home/tom. We can change this default folder when creating user in Linux. Our Tom user can do what ever he wants in /home/tom folder where he have full rights on the files he created and owned in that folder.

The properties of /home folder?

1) A separate sub folder ie /home/ is present for each user.
2) Only user who owns this sub folder can access its content other than root user. So, tom user can not access Barbi user home directory content which is located at /home/barbi.
3) All his terminal properties, command history file, application setting files(

/.ssh) etc everything is located in this folder.
4) System admins when try to implement quota for users they will implement it on /home directory. This /home directory should be mounted on a separate partition.

Читайте также:  Acer configuration manager windows 10 что это

Each user home directory is important and frequently used directory for that user, we have alias name for it. This alias is set to

so that when ever user wants to navigate to his home directory, he do not have to use /home/ but just use below short cuts.

Источник

Get home directory in Linux

I need a way to get user home directory in C++ program running on Linux. If the same code works on Unix, it would be nice. I don’t want to use HOME environment value.

AFAIK, root home directory is /root. Is it OK to create some files/folders in this directory, in the case my program is running by root user?

is it not? As in cd

is implemented by the shell, not the kernel or libc. When programming in C++, you need to implement that yourself.

3 Answers 3

You need getuid to get the user id of the current user and then getpwuid to get the password entry (which includes the home directory) of that user:

Note: if you need this in a threaded application, you’ll want to use getpwuid_r instead.

You should first check the $HOME environment variable, and if that does not exist, use getpwuid.

Also note, that if you want the home directory to store configuration or cache data as part of a program you write and want to distribute to users, you should consider following the XDG Base Directory Specification. For example if you want to create a configuration directory for your application, you should first check $XDG_CONFIG_HOME using getenv as shown above and only fall back to the code above if the variable is not set.

If you require multi-thread safety, you should use getpwuid_r instead of getpwuid like this (from the getpwnam(3) man page):

Источник

How to open a folder in linux via terminal? [closed]

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 7 years ago .

How can I open a folder in a dir?

say I change my current directory to: cd /root/dir/

then I list all the files there: ls folder1 folder2 folder3

Now I want to open folder1. If I try the «./» I get: ./folder1 bash: ./folder1: Is a directory

How can I do so without having to type cd again ie: cd $(pdw)/folder1

5 Answers 5

If you want to open the folder via the nautilus file manager, you can move to the wanted directory like you’ve mentioned cd /root/dir/ , check the folders under that path using ls and then if you want to open folder1 type:

./ is used to execute file (Not to open directory).

(In)CLI Method: You can open folder in terminal by cd folder1 or dir folder1 or ls folder1 .

(To)GUI Method: If you want to open with file-manager (ex:nautilus) then type nautilus folder1 (for Ubuntu nautilus is default file-manager)

I have found that simply typing gnome-open «any-oject» opens any folder or file in the default program on Ubuntu. If this happens to be a folder, it uses your default folder-explorer 🙂

zsh shell can do that with the AUTO_CD option.

Just put setopt AUTO_CD in your .zshrc file (start zsh one time first to create the zsh environment files). You can invoke directly zsh at the terminal prompt to start a zsh session or you can change your default shell to be zsh with the chsh command.

Btw this is not a strange feature, crossable directories do have the «execute» attribute so it makes sense to able to execute a directory like any standard commands.

Источник

Оцените статью