Jump to content

How to create directories and files in the terminal on Linux Ubuntu

 

How to make files into a folder like this photo? There is a home directory on linux, right? And there are other directories in the home directory. Desktop, Pictures, Documents ... yes?

How to make a folder in the home directory with the terminal?

2.png

1.png

Link to comment
Share on other sites

Link to post
Share on other sites

mkdir ~/foldername

 

mkdir = make directory

~ = the currently signed in users home directory (except for root who has a special folder)

foldername = whatever you want the folder to be

 

If you want to do it for other users then you need either SUDO or to be root then its

 

mkdir /home/username/foldername

 

or if you do have root its easier to just su to the user you want to edit and use the ~ alias.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, whispous said:

Pytasz jak stworzyć folder lub jak wyświetlić foldery jak na obrazku?

How to create a folder I know you need to write mkdir and the name of the folder. But I don't know how to create something like the picture

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, Dutch_Master said:

Dodaj stronę do ulubionych:

https://ss64.com/bash/

 

Do tworzenia katalogów potrzebne jest polecenie mkdir.

Thanks for the command page. Are all the linux commands there?

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, Master Disaster said:

mkdir ~/nazwa folderu

 

mkdir = utwórz katalog

~ = katalog domowy aktualnie zalogowanych użytkowników (z wyjątkiem roota, który ma specjalny folder)

nazwa folderu = dowolny folder, który ma być

 

Jeśli chcesz to zrobić dla innych użytkowników, potrzebujesz SUDO lub być rootem, wtedy jest

 

mkdir /home/nazwa użytkownika/nazwa folderu

 

lub jeśli masz root, łatwiej jest po prostu podpisać użytkownika, którego chcesz edytować i użyć aliasu ~.

To create something like the picture you need to have a root?

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, GamerGry123 said:

How to create a folder I know you need to write mkdir and the name of the folder. But I don't know how to create something like the picture

You cannot just create a picture out of nothing. If you mean create an empty file then the command you want is touch.

 

For example...

 

touch ~/Documents/picture.jpeg

 

...would create an empty file in your Documents folder called picture.jpeg.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, GamerGry123 said:

To create something like the picture you need to have a root?

In someone else's home directory yes, in your own home directory no.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Master Disaster said:

Nie można po prostu stworzyć obrazu z niczego. Jeśli masz na myśli utworzenie pustego pliku, to poleceniem, które chcesz, jest dotyk.

 

Na przykład...

 

dotknij ~/Dokumenty/obraz.jpeg

 

...utworzy pusty plik w folderze Dokumenty o nazwie picture.jpeg.

Okay, and you don't need root for that? I know that this is how the file is created.

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Master Disaster said:

W cudzym katalogu domowym tak, we własnym katalogu domowym nie.

My point is that you have a home directory in the file explorer, in it directories desktop, documents, images and others, in it I want to create a directory using commands

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, GamerGry123 said:

Okay, and you don't need root for that? I know that this is how the file is created.

If you're creating something in your own home folder no you don't need root.

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Master Disaster said:

Jeśli tworzysz coś we własnym katalogu domowym, nie potrzebujesz roota.

Okay, but with the terminal I don't know how to do it, you can do it by clicking the mouse but I don't know how to write the command

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Master Disaster said:

Jeśli tworzysz coś we własnym katalogu domowym, nie potrzebujesz roota.

Why, as I write in the tree command as in the picture, it does not show standard directories such as document, images?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, GamerGry123 said:

My point is that you have a home directory in the file explorer, in it directories desktop, documents, images and others, in it I want to create a directory using commands

Oh I think I understand now, you need to install the tree package, if you're on Ubuntu its

 

sudo apt install tree

 

then you just use tree instead of ls

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, Master Disaster said:

Och, myślę, że teraz rozumiem, musisz zainstalować pakiet drzewa, jeśli jesteś na Ubuntu to

 

drzewo instalacji sudo apt

 

wtedy po prostu używasz drzewa zamiast ls

Well, now everything works, but I knew how to do it all folders files but because I didn't know how to show them I thought they were not in the home directory. Thanks

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Master Disaster said:

Och, myślę, że teraz rozumiem, musisz zainstalować pakiet drzewa, jeśli jesteś na Ubuntu to

 

drzewo instalacji sudo apt

 

wtedy po prostu używasz drzewa zamiast ls

How to delete a selected file or folder with a command?

Link to comment
Share on other sites

Link to post
Share on other sites

Delete a file with...

 

rm filename (if its in the current directory)

or

rm /file/path/here (to specify an absolute path)

 

Delete a folder with...

 

rm -R /folder/path/here

*note the R must be a capital otherwise it won't work.

 

Deleting a folder will also delete any files it contains.

 

Main Rig:-

Ryzen 7 3800X | Asus ROG Strix X570-F Gaming | 16GB Team Group Dark Pro 3600Mhz | Corsair MP600 1TB PCIe Gen 4 | Sapphire 5700 XT Pulse | Corsair H115i Platinum | WD Black 1TB | WD Green 4TB | EVGA SuperNOVA G3 650W | Asus TUF GT501 | Samsung C27HG70 1440p 144hz HDR FreeSync 2 | Ubuntu 20.04.2 LTS |

 

Server:-

Intel NUC running Server 2019 + Synology DSM218+ with 2 x 4TB Toshiba NAS Ready HDDs (RAID0)

Link to comment
Share on other sites

Link to post
Share on other sites

-= Topic moved to Linux, macOS and Everything Not-Windows =-

COMMUNITY STANDARDS   |   TECH NEWS POSTING GUIDELINES   |   FORUM STAFF

LTT Folding Users Tips, Tricks and FAQ   |   F@H & BOINC Badge Request   |   F@H Contribution    My Rig   |   Project Steamroller

I am a Moderator, but I am fallible. Discuss or debate with me as you will but please do not argue with me as that will get us nowhere.

 

Spoiler

  

 

Character is like a Tree and Reputation like its Shadow. The Shadow is what we think of it; The Tree is the Real thing.  ~ Abraham Lincoln

Reputation is a Lifetime to create but seconds to destroy.

You have enemies? Good. That means you've stood up for something, sometime in your life.  ~ Winston Churchill

Docendo discimus - "to teach is to learn"

 

 CHRISTIAN MEMBER 

 

 
 
 
 
 
 

 

Link to comment
Share on other sites

Link to post
Share on other sites

man ls

 

Hit the / key, type recursive and press enter.  Hit q when done.  That's assuming you are using English as default language.

 

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, heimdali said:

man ls

 

Hit the / key, type recursive and press enter.  Hit q when done.  That's assuming you are using English as default language.

 

that view is done with tree, not ls

Link to comment
Share on other sites

Link to post
Share on other sites

@10leej

 

Right, yet ls may also be helpful.  Tree can be somewhat unwieldly and take quite a while for displaying directories, especially when you're trying to learn how create a directory structure or when you have more than a few files in one.

 

Last time I used tree must have been in the 90ies when it was cool to have a program that could produce fancy output like that, and I had forgotten about it 🙂  Aside from the coolness I never found it very useful.

 

Hm, it's still cool, though, and has lots of options.  Maybe I should use it more often.  Interestingly, it's installed by default on Fedora Workstation.

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×