date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,571,519,943,000
I have been asked to measure the contention of locks a write process is causing. I was looking at the data of the lockstat for that write process. My questions are below: Is contention related to the number of times threads wait for the particular lock, as it is taken by another thread or the time for which threads ...
Looking at the Linux kernel docs it looks like it it's waiting for the lock to get freed. - HOW Lockdep already has hooks in the lock functions and maps lock instances to lock classes. We build on that (see Documentation/locking/lockdep-design.txt). The graph below shows the relation between the lock functions and th...
What is contention? [closed]
1,571,519,943,000
I often hear that linux threads are heavy (requiring 8mb stack size) and this is why languages like golang implement their own green threads in userspace (allocating to the heap). This then allows handling say 100k connections instead of 10k connections. As I understand it, one problem with this is interop with C, and...
I often hear that linux threads are heavy (requiring 8mb stack size) Can see where that claim comes from: A system (posix) thread's size depends on how you configure the task allocator. The default on modern 64 bit systems is indeed 8 MB, because that size kind of makes sense. Usually it grows far less, and I'm not ...
Why can't Linux provide lighter/green threads?
1,571,519,943,000
The motivation behind this question arises from exploring the Intel Galileo gen2 board which has a single threaded processor. I'm looking for a conceptual explanation on what does that mean for all the userspace applications that rely on the existence of threading? Does this mean that the kernel needs to be patched ...
Multi-tasking systems handle multiple processes and threads regardless of the number of processors or cores installed in the system, and the number of "threads" they handle. Multi-tasking works using time-slicing: the kernel and every running process or thread each get to spend some time running, and then the system s...
Multithreaded applications on a single threaded CPU?
1,571,519,943,000
From this answer - software threads vs hardware threads, software threads are threads managed by OS. But I also learn another term called user threads, which are threads that's not kernel threads, i.e. the OS won't know about these threads. So does software threads include user threads? I didn't get any answer from st...
This is an area where terms tend to be overloaded — the same term is used with different meanings depending on the context. It’s not helped by the fact that the meaning commonly associated with various terms changes over time, so the age of the texts you’re reading is important. There are a number of aspects to distin...
Does software threads include user threads?
1,571,519,943,000
I am studying OCFS2 kernel source code and I found this comment of function dlm_lanuch_thread in file fs/ocfs2/dlm/dlmthread.c: /* Launch the NM thread for the mounted volume */ So what does the "NM thread" mean?
From the user's guide, section 4, "O2CB Cluster Service": NM: Node Manager that keep[sic] track of all the nodes in the cluster.conf
What's a NM thread?
1,398,727,421,000
Some of the servers I use traceroute on, are more than 30 hops away. How do I make traceroute trace beyond 30 hops?
From man 1 traceroute: -m max_ttl Specifies the maximum number of hops (max time-to-live value) traceroute will probe. The default is 30.
How to make traceroute trace beyond 30 hops?
1,398,727,421,000
Here is the route path from my home to sina.com.cn. traceroute -n sina.com.cn traceroute to sina.com.cn (202.108.33.60), 30 hops max, 60 byte packets 1 192.168.31.1 0.476 ms 0.587 ms 0.695 ms 2 140.0.5.1 2.557 ms 2.699 ms 3.065 ms 3 221.11.155.65 4.501 ms * 221.11.165.9 5.045 ms 4 * 221.11.156.18 2...
What traceroute does is use the option fields as it sends internet control message protocol (icmp) packets. Each Gateway or routing point in the network reads packets on one interface, decides where they ought to go, and writes them out on another interface. That interface is presumably closer to the destination. Wh...
Why does traceroute display many ip addresses for the same hop?
1,398,727,421,000
The implementation of traceroute(tracert) differs on Windows and Unix. I wanted to compare both with Wireshark. I am on Windows 7 now and I wanted to get Unix traceroute implementation quickly. My first idea was to get it using MSYS or Cygwin. I installed Cygwin with "inetutils*" packages checked, but there is no trac...
Ok, as Stephen Kitt said there is no ready to use traceroute binaries for Cygwin. That's why i tried to compile it myself. I can see there is modern traceroute but from it's description follows, that it can't be used with old Linux kernels and for me compilation stuck on missing "dccp.h" and i gave up. I was able to c...
How to get traceroute on cygwin?
1,398,727,421,000
I'm a Linux Mint user. I've run traceroute on Linux and tracert on Windows. On Linux, I just get asterisks. Everything seems to work fine on Windows. Here are the outputs Windows: Linux Mint: Why is this happening and is there something I can do to solve this problem?
A likely reason for the difference is that by default Window's tracert uses ICMP, whereas Linux traceroute defaults to UDP. Using the -I option for traceroute should produce the same results as tracert: traceroute -w 10 -I google.it From the traceroute documentation: In the modern network environment the traditional...
Traceroute doesn't work on Linux, on Windows it does
1,398,727,421,000
how to determine if the server is slow or not with traceroute unix command . Here is the traceroute Out put of a host IP . traceroute 188.165.247.43 traceroute to 188.165.247.43 (188.165.247.43), 30 hops max, 60 byte packets 1 iPhone.local (172.20.10.1) 1.493 ms 2.546 ms 3.287 ms 2 * * * 3 10.52.141.50 (10....
From your output, you are not able to reach the destination. The * denotes a timeout. traceroute command shows the path to your destination. packets send to will pass through the routers and you receive a response obeying the time to live (TTL) value for each packets. the * denotes a timeout as a response from the int...
How to use traceroute command in unix
1,398,727,421,000
My traceroute6 results are truncated, while the results from mtr span the whole path. Why would this happen? mtr uses ICMP ECHO by default, just like traceroute. Running traceroute under sudo does not change the result. Nor does -M tcp or -M udp or -M icmp. (Note I am deliberately testing the "production version of...
The traceroute manpage says !X indicates one of the ICMP error responses (other than the desired "TTL exceeded"). traceroute gives up when it sees one. It looks like mtr is more robust. It's a weird case. I can't think why you'd replace a "TTL exceeded" response with "administratively prohibited", when packets with...
Why is mtr more reliable than traceroute, on my ISP?
1,398,727,421,000
I can't find any info regarding this in the man-pages. How would one go about only printing the gateway using traceroute?
With traceroute you've to enter maximum hop as 1 using m1 option as follows. traceroute -m1 google.com According to basic rules of computer network Gateway and host must be connected to same NIC of router. Otherwise Data Link Layer will unable to deliver packets from hosts to Gateway. So it's hop should be 1. So by s...
traceroute, only print gateway information
1,398,727,421,000
I often run into a situation where I want to traceroute an IP without root or NET_RAW cap in Linux. I have attempted to send a UDP packet with a small TTL but no ttl error is emitted at all. It seems that getting the TTL exceeded error requires using an ICMP socket. Is it possible to use UDP or TCP protocol only witho...
Of course, you can use any protocol. Try tcptraceroute. Or the standard traceroute. from man page: -I, --icmp Use ICMP ECHO for probes -T, --tcp Use TCP SYN for probes -U, --udp Use UDP to particular destination port for tracerouting (instead of increasing the po...
It is possible to traceroute without touching ICMP?
1,398,727,421,000
traceroute sends UDP packets to port 33434 (and up) by default. I assume mtr -u (manual, homepage, github) does the same, but I can't find any documentation or test results to verify the destination port numbers. Does mtr -u use destination port 33434 and then increment, like traceroute?
TL;DR By default, it starts at 33000 and goes up. You can observe it if you run a network trace at the same time: tcpdump -i any -n host 8.8.8.8 & mtr -u --report -c 1 8.8.8.8 21:21:50.777482 IP [redacted].31507 > 8.8.8.8.33000: UDP, length 36 21:21:50.877579 IP [redacted].31507 > 8.8.8.8.33001: UDP, length 36 21:21:5...
What UDP destination port(s) does mtr -u use?
1,398,727,421,000
I have the below error: [root@~]# traceroute -s 'publicIP' 8.8.8.8 traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets **bind: Cannot assign requested address** But when i did not enter source, it works fine: [root@pf-apispens ~]# traceroute 8.8.8.8 traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte pack...
You need to type traceroute -s with addresses which directly assign to any interfaces on your server. You can type any of this addresses from your output of ip a: 192.168.111.xyz 192.168.111.xyzz But not real public ip because it has assigned to your other device (e.g. router). See man traceroute: -s source_addr, -...
traceroute have error bind: Cannot assign requested address
1,398,727,421,000
I'd like to learn why traceroute sends three packets per hop by default. (Nothing important, I'm just curious). Edit: packages != packets
First, they're called "packets", not "packages". Multiple packets result in more information. Soft failure, asymmetric routing, and other network weirdness can't be seen with a single packet. With 2 packets, which result do you believe? With 3 packets, ... OTOH, programmer picked a default.
Why does traceroute send three packets?
1,398,727,421,000
I thought TCP protocol itself will guarantee not to loose any bytes while connecting. About this viewpoint, please refer to https://stackoverflow.com/questions/23841896/will-tcp-connection-lose-packets What puzzled me was how mtr (run with TCP protocol) calculate loss? TCP just has segment rather than packets. So, wh...
Analysis From what I can gather looking over the docs & via Google it looks like mtr is tracking packet loss itself by sending traffic and then keeping track of any drops that occur due to network congestion. For example, the Linode tutorial titled: Diagnosing Network Issues with MTR states the following: The i optio...
How does MTR (run with TCP protocol) calculate the loss rate?
1,398,727,421,000
I'm using the traceroute utility to test network connectivity. The problem is usually with slow speed - that means, the webpages in the browser are often displayed very slowly. Sometimes the speed of rendering HTML page is better, but the videos from youtube are transfered very slowly, so that you can watch it usually...
First, since your browser makes connections to multiple hosts, you need to know which one to check (if you don't already). There are a number of tools that can passively gather TCP statistics. Now, mtr is a tool specifically created to measure connection reliability and output reports that can be sent to ISPs verbatim...
Traceroute - approach the place with connectivity issues
1,398,727,421,000
We have a managed server with centos, recently it starts showing strange behavior: root@server [/tmp]# ping www.google.com PING www.google.com (172.217.8.196) 56(84) bytes of data. 64 bytes from ord37s09-in-f4.1e100.net (172.217.8.196): icmp_seq=1 ttl=53 time=24.8 ms So this looks quite good. And here it becomes st...
You did not use fully-qualified domain names. www.google.com is not a fully-qualified (human readable form) domain name. It does not end with a dot. You also have a search path of plannersys.net. configured in your DNS client library and a wildcard DNS resource record for *.plannersys.net.. As a consequence of the...
Why does ping resolve to a different address than traceroute? and lynx?
1,398,727,421,000
EDITED: SOLUTION FOUND: After contacting godaddy, a solution was found very fast (great service!). What seemed to be the problem was that my IP Address was being blocked, given that I had too many failed login attempts. After requesting the IP to be unblocked and waiting a little bit the problem was solved. If the go...
In most of these cases, the problem comes from the IP being blocked on the server for security reasons such as too many failed login attempts and the such. That kind of situation can only be resolved by the host's security team or waiting long enough for the automatic block to be removed, typically 24 hours.
PuTTY (SSH) (tracert) Network error: Software caused connection abort
1,398,727,421,000
First I try running nmap -sn ip/24 to check live hosts on a subnet. It returns that all 255 hosts are live which I know is not true. I do fping -g ip/24 and get that 7 hosts are up which makes more sense. Now I'm trying to figure out network topology using nmap -sn --traceroute ip/24 and the entire range of 0-255 is ...
you could use fping output as nmap target list: fping -aqg ip/24 | xargs nmap -sn --traceroute If your problem is that some gateway in your network is giving fake ARP responses (generating false positives), you can use -sn -PE to fix that: nmap -sn -PE --traceroute ip/24 That way, nmap will exclusively show a host ...
how to use only certain addresses in subnet for traceroute?
1,398,727,421,000
I have a domain and when I use dig jeeja.biz it just gives me my server ip address. ;; ANSWER SECTION: jeeja.biz. 13914 IN A 209.15.212.171 But when I use the same command on another site: dig ilportaledellautomobilista.it the replay is: ;; AUTHORITY SECTION: ilportaledellautomobilista.it. 3600 IN SOA d...
It would seem that ilportaledellautomobilista.it does not have an A record, however the domain does exist and does have a nameserver (SOA shows that). Since that host only has a SOA record, thats what dig is returning. www.ilportaledellautomobilista.it does have an A record though. So give that a try instead, and you ...
dig domain replay SOA
1,398,727,421,000
I'm just in the process of setting up my Linux (Debian-based) router with a PPPoE connection via an ADSL/PPPoA -> PPPoE bridge. The connection works perfectly on the router itself but a traceroute through the NAT for some reason takes a long time to get the result of the first hop (to the NAT). The majority of the tim...
Answer turned out to be the router had 2 virtual interfaces on one physical interface. Problem was solved by getting iptables to use only the virtual interface eth0:0 for the routing.
iptables - masqueraded NAT has delayed first hop in traceroute
1,398,727,421,000
I am trying to get traceroute installed with: $ sudo apt-get install inetutils-traceroute $ traceroute --version traceroute (GNU inetutils) 1.9.4 Copyright (C) 2015 Free Software Foundation, Inc. to work over TCP on Ubuntu 19.10 but it gives: $ traceroute -T google.com traceroute: invalid option -- 'T' Try 'tracerou...
You need to install the traceroute package which provide the modern traceroute command: sudo apt install traceroute sudo apt remove inetutils-traceroute Or -without removing inetutils-traceroute- you can use sudo update-alternatives --config traceroute to switch between traceroute versions.
traceroute: invalid option -- 'T' (Ubuntu 19.10)
1,392,163,975,000
I have a freebsd box, which serves as a router from LAN to the outside world. It has several Internet providers, OpenVPN servers and clients, NAT and so on. I would like to have complete statistics on when, who, to whom, via which provider, via which protocol, and how many bytes have been sent. I agree that the minim...
For getting details of network transactions, you have got a implementation of a Netflow generator for FreeBSD or Linux: ng_netflow NAME ng_netflow - Cisco's NetFlow implementation DESCRIPTION The ng_netflow node implements Cisco's NetFlow export protocol on a router running FreeBSD. The ng_netfl...
How to gather full network usage statistics on a freebsd router?
1,392,163,975,000
How can I remove a single filter? tc filter show dev peth1 shows filter parent 1: protocol ip pref 16 u32 filter parent 1: protocol ip pref 16 u32 fh 800: ht divisor 1 filter parent 1: protocol ip pref 16 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:2 match 5bd6aaf9/ffffffff at 12 Why does that not work?: tc...
Old post, but for reference, it wouldn't work for a few reasons: The priority should be 16 and not 1 The filter handle should be 800::800 and not 800:800 You must supply the parent qdisc that the filter is attached to This should work: tc filter del dev peth1 parent 1: handle 800::800 prio 16 protocol ip u32
remove tc filter (Traffic Shaping)
1,392,163,975,000
Playing around with some low level functions to monitor my system stats. I would like to get the current network utilization the same way like I can get cpu temp cat /sys/class/thermal/thermal_zone0/temp or fan speed cat /sys/class/hwmon/hwmon6/fan1_input Looking at /sys/class/net/my_network_adapter/ I didn't find ...
To get the rate of B/s, no need of anything but your shell: Simply read rx_bytes file at each second and compare the current value with the value one second before. rx1=$(cat /sys/class/net/wlp3s0/statistics/rx_bytes) while sleep 1; do rx2=$(cat /sys/class/net/wlp3s0/statistics/rx_bytes) printf 'Download rate:...
Get current network utilization via /sys/class/net
1,392,163,975,000
I have noticing that, lately, my Odroid's ethernet LED is constantly blinking, even when I'm expecting no traffic. I ran iptraf and, besides the attempts of SSH brute force guess attempts (that are then blocked by fail2ban) I didn't see any TCP traffic. However, I noticed a massive amount of UDP traffic on port 123 th...
You state that I have stopped ntpd Then what you have been observing is nearly surely illegal activity. UDP/123 being a IANA-assigned port, it cannot be used by any other legitimate application: the Official IANA port assignment page states: Assigned ports both System and User ports SHOULD NOT be used without or...
Ubuntu - UDP Traffic on port 123
1,392,163,975,000
I am looking at a virtual server tariff that has limited outgoing traffic for a month, with billing if the traffic is exceeded. I would like to track the outgoing traffic automatically somehow, so that I can automatically can stop the service if the limit is being approached. What tool can I use for this in Linux? Tha...
OK, not knowing what the limit is or how good you are at scripting, here a suggestion. Install vnstat - on Ubuntu that will automatically launch the accompanying demon process, which will immediately start monitoring the network (only for traffic stats, not content snooping). You can look at it interactively, like so:...
Limit outgoing traffic per month
1,392,163,975,000
I'd like to find out how much network traffic my computer uses, i.e. whether a limit of 30GB of transfer wouldn't be too little. What's the best tool to measure it? Using Linux Mint 17
vnstat is a CLI option. vnstat can run as a daemon that can be queried from CLI. apt-get install -y vnstat # install the software vnstat -u -i eth0 # enable monitoring of eth0 by default service vnstat restart # this may not work on Mint, I don't have a system to test with, but it does work on CentOS vnstat -h # show...
Measure the network traffic on a long-term basis
1,392,163,975,000
I am trying to limit the download (ingress) rate for a certain app within a cgroup. I was able to limit the upload (egress) rate successfully by marking app's OUTPUT packets in iptables and then set a tc filter to handle that marked packets. However, when I did the same steps for ingress it didn't work. steps I follo...
As per @A.B comments: The mark you set in mangle/INPUT has no effect on tc, because tc ingress happens waaaay before. Check: en.wikipedia.org/wiki/Netfilter#/media/ ... To save the mark for the connection, use -j CONNMARK --save-mark for cgroup's outbound packets, retrieve connmark in inbound packets with tc-connma...
How to police ingress (input) packets belonging to a cgroup with iptables and tc?
1,392,163,975,000
What's the most effective way to monitor SSH access in Gentoo Linux? My Gentoo box is operating locally behind my broadband router. I have SSH port forwarding on the router and a DNS entry pointing to my router on the internet. Is there a way to silently record what external domain/IP the incoming connection to my Gen...
User authorization events are typically logged by the system logging daemon in /var/log. The default locations vary between distros, but it is often /var/log/auth, /var/log/auth.log, /var/log/secure. I don't have a Gentoo system handy, but the default install used to feature syslog-ng and log these events to /var/log/...
How to transparently monitor SSH access/network traffic in Gentoo/general linux?
1,392,163,975,000
How can I log quantities of IP traffic by src/dst (and port for UDP & TCP)? For each interval (probably each hour) I would like to see something like: proto, src, dst, packets, octets ICMP, 192.168.1.3, 2.3.4.5, 34, 483 TCP, 192.168.1.3:34821, 2.3.4.5:80, 123, 23408 TCP, 192.168.1.3:33812, 5.6.7.8:22, 201, 2039 TCP, 1...
You can get byte and packet counts from conntrack. To enable counters, set accounting #sysctl net.netfilter.nf_conntrack_acct=1 Then you will see conntrack ouput like this #conntrack -L tcp 6 431971 ESTABLISHED src=192.168.0.156 dst=192.168.0.1 sport=53474 dport=443 packets=11 bytes=1945 src=192.168.0.1 dst=192...
How to log quantities of IP traffic by src/dst (and port for UDP & TCP)?
1,392,163,975,000
I have a problem on my Redhat computer. I do have incoming traffic on a network interface, let's call it eth1. I also have outgoing traffic on another network interface, let's call it eth2. When the route for outgoing traffic is not set, incoming traffic is correctly received on eth1 (a program is using information co...
As Christopher said: Does this information help? Maybe not the same scenario, but probably relevant. Separate Network Traffic on Two Network Interfaces This helped as disabling reverse path filtering solved this issue.
Route blocking incoming traffic
1,347,356,961,000
I need to print the directory structure of our production system and I would like to remove some specific directories from the tree? How do we specify multiple ignore patterns for tree command?
You simply provide all the patterns to the -I command, separated by |. From the manpage: -P pattern List only those files that match the wild-card pattern. Note: you must use the -a option to also consider those files begin‐ ning with a dot `.' for matching. Valid wildcard operators are ...
How do we specify multiple ignore patterns for `tree` command?
1,347,356,961,000
I like tree it's a nice way to display my files and the size of folders/directories. But the -h option only shows the size of the directory, not the cumulative size of its contents. /media/ ├── [ 16K] 64D9-E862 │   ├── [8.0K] downloads I know for a fact that my external drive has more that 16kB in it. How can I fix...
Only for tree 1.6 and above You might want to look at: man tree --du For each directory report its size as the accumulation of sizes of all its files and sub-directories (and their files, and so on). The total amount of used space is also given in the final report (like the 'du -c' ...
Print size of directory content with tree command in tree 1.5?
1,347,356,961,000
The "tree" command uses nice box-drawing characters to show the tree but I want to use the output in a "code-page-neutral" context (I know that really there's always a code page, but by restricting it to the lower characters I hope to be free of worries that someone in Ulan Bator sees smiley faces, etc). For example ...
I'm not sure about this but I think all you need is tree | sed 's/├/\+/g; s/─/-/g; s/└/\\/g' For example: $ tree . ├── file0 └── foo ├── bar │   └── file2 └── file1 2 directories, 3 files $ tree | sed 's/├/\+/g; s/─/-/g; s/└/\\/g' . +-- file0 \-- foo +-- bar │   \-- file2 \-- file1 2 directo...
"tree" command output with "pure" (7-bit) ASCII output
1,347,356,961,000
I want to cat a file in current folder and all files in all subfolders (and subsubfolders). Here is my directory structure $ tree . ├── f │   └── foo └── yo I want to cat foo and yo. I've tried this command but did not work: cat */* It just cats foo.
try: find . -type f -exec cat {} +
cat files in current folder and all subfolders [duplicate]
1,347,356,961,000
I'm wondering if we can combine the honesty of 'du' with the indented formatting of 'tree'. If I want a listing of the sizes of directories: du -hx -d2 ...displays two levels deep and all the size summaries are honest, but there's no indenting of subdirs. On the other hand: tree --du -shaC -L 2 ...indents and colo...
Also checkout ncdu: http://dev.yorhel.nl/ncdu Its page also lists other "similar projects": gt5 - Quite similar to ncdu, but a different approach. tdu - Another small ncurses-based disk usage visualization utility. TreeSize - GTK, using a treeview. Baobab - GTK, using pie-charts, a treeview and a treemap. Comes with ...
combine the best of 'du' and 'tree'
1,347,356,961,000
Is there a way to make tree not show files that are ignored in .gitignore?
This might help: list git ignored files in an almost-compatible way for tree filter: function tree-git-ignore { # tree respecting gitignore local ignored=$(git ls-files -ci --others --directory --exclude-standard) local ignored_filter=$(echo "$ignored" \ | egrep -v "^#.*$|^[[:space:]]*...
Have tree hide gitignored files
1,347,356,961,000
I get colored tree using tree -C but when I pipe it to less I get results like this: tree public/ -C | less How can I have colors in less in this case?
You want the -R switch to less. From the less man page: -R or --RAW-CONTROL-CHARS Like -r, but only ANSI "color" escape sequences are output in raw" form. Unlike -r, the screen appearance is maintained correctly in most cases. ANSI "color" escape sequences are sequences of the for...
How can I pipe colored tree result to less or more?
1,347,356,961,000
tree has a -d option to "List directories only.". However, I cannot seem to find an option to "List files only." I have looked through the man page, but I cannot seem to find an option for listing only files.
As others have said in the comments, listing only non-directories doesn't exactly mesh with the purpose of the tree command. However, listing only the files in the current directory is not unusual if you're like me and prefer to use a customized tree over ls (and maybe you've even aliased ls to tree with your preferre...
How to make tree output only files?
1,347,356,961,000
Is there a convenient way to convert the output of the *nix command tree to JSON format? My goal is to convert something like: . |-- dir1 | |-- dirA | | |-- dirAA | | `-- dirBB | `-- dirB `-- dir2 |-- dirA `-- dirB into: {"dir1" : [{"dirA":["dirAA", "dirAB"]}, "dirB"], "dir2": ["dirA", "dirB"]}
Attempt 1 A solution using just perl, returning a simple hash of hashes structure. Before the OP clarified data format of JSON. #! /usr/bin/perl use File::Find; use JSON; use strict; use warnings; my $dirs={}; my $encoder = JSON->new->ascii->pretty; find({wanted => \&process_dir, no_chdir => 1 }, "."); print $enco...
Convert output of tree command to json format
1,347,356,961,000
wget has such option as -np which disables getting files from any parent directory. I need something similar but a bit more flexible. Consider: www.foo.com/bar1/bar2/bar3/index.html I would like to get everything but not "higher" (in the tree hierarchy) than bar2 (!). So bar2 should also be fetched but not bar1. Is t...
I haven't tried it, but using -I and -X could give you what you want. My first tries would be along the line of wget -m -I bar1/bar2 -X "*" http://www.foo.com/bar1/bar2/bar3/index.html Explanation of options: -m: --mirror Turn on options suitable for mirroring. This option turns on recursion and time-sta...
Is there a way to disable wget from getting files from parent directories to given depth?
1,347,356,961,000
Is there any version of tree command that displays file structure as a tree structure, but in a way that I can interactively walk trough? Why do I need it exactly - I am trying to simulate TextMate project drawer using vim and splitscreen with screen and "interactive" tree on the left. But if there is any better way t...
The nerdtree plugin for vim should do just that. It gives you a tree view of your filesystem inside vim that can be used interactively. It supports a dozen features such as bookmarking files, syntax highlighting, mouse support, tree filtering and more. Generally, good stuff to have when working on projects that span m...
Interactive tree command
1,347,356,961,000
I want to list the subdirectories of a directory using tree command. But I don't want to print indentation lines. I only want to have the whitespaces instead. I couldn't find the correct parameter in man page. Maybe I can pipe the output of tree to sed to remove the lines.
So you want something like this: tree | sed 's/├\|─\|│\|└/ /g' It replaces all those "line" characters with spaces. See: $ tree . ├── dir1 │   ├── file1 │   └── file2 └── dir2 ├── file1 └── file2 2 directories, 4 files $ tree | sed 's/├\|─\|│\|└/ /g' . dir1    file1    file2 dir2 f...
Print indentations with whitespace only in tree command
1,347,356,961,000
In plain zsh, tree is set similar to --color=auto by default. However, when I use Oh-My-Zsh, tree doesn't show colors. Since tree does not have a --color=auto option, how can I override the setting back to the auto one?
I found the answer after I posted an issue on Oh-My-Zsh's repository. Color in tree rely on LS_COLORS, which is not set by Zsh by default; but my ~/.zshrc set the variable after I hit "use default setting" option, with a single line eval "$(dircolors -b)" which looks insignificant. After installing Oh-My-Zsh, the set...
Automatically colorize the output of tree
1,347,356,961,000
I have a shell script executes tree command $ cat _tree.sh #!/bin/sh tree -L 2 --charset ascii -I "_tree.sh|LICENSE|README.md|node_modules|nbproject" $ sh _tree.sh . |-- bower.json |-- dpl |-- dst |-- gulpfile.js |-- package.json `-- src |-- fonts |-- images |-- scripts `-- styles 7 directories, 3 f...
To append trailing slashes for directories, simply revise your code to include the -F option, in _tree.sh: tree -F -L 2 --charset ascii -I "_tree.sh|LICENSE|README.md|node_modules|nbproject" Explanation The tree program (for example version 1.7.0) does not append trailing slashes by default. As @steeldriver points ou...
tree command in a shell script doesn't append slashes for directories
1,347,356,961,000
I need to look into a particular directory and list the number of files per level. The directory is pretty large, about 10-15 levels deep. For instance, if I have the following: D1 | |-- D2A (5 files in this directory) | |-- D3A (6 files in this directory) | |-- D3B (7 Files in this directory) | |-- D2B (1 file ...
find . -type d | \ perl -ne 'BEGIN{ sub cnt{ $file=shift; $c="find $file -maxdepth 1 -type f | wc -l";int(`$c`) }} chomp; printf "%s %s\n", $_, cnt($_)' | \ perl -ne '/^(.*) (\d*)$/; $_{scalar(split /\//, $1)}+=$2; END { printf "Depth %d has %d files.\n", @$_ for map { [$_,$_{$_}] } sort keys %_ }' Results: Depth 1 h...
Can tree be used to list the number of files per level?
1,347,356,961,000
I'm trying to figure out if there is a way to get the UNIX command tree to display only directories that match a specific pattern. % tree -d tstdir -P '*qm*' -L 1 tstdir |-- d1 |-- d2 |-- qm1 |-- qm2 `-- qm3 5 directories The man page shows this bit about the switch. -P pattern List only those file...
Yes, it's a bug. From man page: BUGS Tree does not prune "empty" directories when the -P and -I options are used. Tree prints directories as it comes to them, so cannot accumu‐ late information on files and directories beneath the directory it is printing. ... at all, -d switch ask to not print file...
Can the UNIX command tree display only directories matching a pattern?
1,347,356,961,000
I've been searching for this for a while and didn't get a satisfactory answer for it. I've taken this screenshot from the output of Gnu/Linux's tree command. I want to know how to draw or print lines like these, I've tried reading the source code of the tree program but didn't understand anything.
It requires special box-drawing characters, as commented by another user. In the terminal, it is possible to call them via the printf command. For example, to recreate the first two lines of the tree example in the question, it would look like: printf "\x1b(0\x74\x1b(B\x1b(0\x71\x1b(B\x1b(0\x71\x1b(B info\n" printf "\...
How to draw a continuous line in terminal?
1,347,356,961,000
I'm trying to sort by size: % tree -axCF --du --sort=size | grep -e '/$' ├── [ 8658884] 2022-10-09-backup/ ├── [ 5923934] f24-01-22-backup/ ├── [ 5384825] e2023-01-19-backup/ ├── [ 3627525] h24-01-22-npanelize-nselect/ ├── [ 2162140] b2022-12-18-backup/ ├── [ 1255661] a2022-12-12-backup/ ├── ...
tree versions 1.7.0 and 1.8.0 didn’t take --du into account when sorting by size: directories were sorted by their own size, not the size of their contents. This was fixed in version 2.0.0.
tree command with 'sort=size' seems imperfect
1,347,356,961,000
I am using a simple combination of commands to "monitor" a bit of my filesystem change: watch and tree. Except I want colours and can't get it. Here's what I thought should work: watch --color 'tree -C' which kind of works since it gives me some colours, but not in the same way as tree -C by itself. Here's some screen...
The basic problem is that watch and tree use different information for getting the colors: The watch program interprets standard (ECMA-48) escape sequences for specifying video attributes. That means 8 colors, plus bold, blink, underline, reverse and italics. It uses (n)curses to display the information, making the...
tree(1) colours not properly interpeted by watch(1) even with --color option
1,347,356,961,000
I'm trying to figure out if there is a way to get the UNIX command tree to display only directories that match a specific pattern. % tree -d tstdir -P '*qm*' -L 1 tstdir |-- d1 |-- d2 |-- qm1 |-- qm2 `-- qm3 5 directories The man page shows this bit about the switch. -P pattern List only those file...
Someone mentioned on stackoverflow in the trees man page that this is why the -P switch doesn't exclude things that don't match the pattern. BUGS Tree does not prune "empty" directories when the -P and -I options are used. Tree prints directories as it comes to them, so cannot accumu‐ late information o...
Can the UNIX command tree display only directories matching a pattern?
1,347,356,961,000
I would like to see the tree of a big compressed file (specifically only the second level of directories) so I used the following command: tar -tf tarfile | tree -L 2 But it outputs the tree of the directory I am in, not of the compressed file. The other commands work fine, for example if I do: tar -tf tarfile | le...
Since tree does not read stdin, but instead traverses the actual directory structure (whether the current directory or the specified directories), you would need to post-process the table of contents of the tar file. If the tar file was created with full/absolute path names, you'll need to adjust the ranges to find yo...
pipe of tar and tree commands?
1,347,356,961,000
I've read through the man pages for tree but I don't know if it is possible to have tree list only the filenames for all files that appear in any recursive search of a directory. The closest I have gotten is: tree -i --noreport dir/ which might give me something like: ./lib order crossCount.js rank acyclic.js Where o...
I think tree normally needs to print the directory name to get the tree-like structure. How about using find instead? find dir/ -type f with above command you can get all and only files (-type f) recursively. It displays with path of the file, though. In case that you don't want to display the path of the file, you c...
Getting tree command to not display directories
1,347,356,961,000
If I understand correctly, in Linux, everything is a path, right down to each piece of hardware. I am trying to get information about how my sensors are structured, so I thought I would just use tree to map out all the things in my hwmon directory. However, tree does not behave the same with this directory as I am acc...
tree behaves that way because it doesn’t dereference symlinks by default. The -l option will change that: tree -l /sys/class/hwmon/ but you’ll have fun making sense of all the output.
Why can't tree fully list /sys/class/hwmon? And how could I do that?
1,347,356,961,000
For the following tree structure: . └── dir1 └── dir2 └── dir3 What would be a simple way to create a file (could be empty), for every directory, so the resulting tree will look like: . ├── dir1 │   ├── dir2 │   │   ├── dir3 │   │   │   └── README │   │   └── README │   └── README └── README
You can do that with find: find . -mindepth 1 -type d -exec touch "{}/README" \; Explanation -mindepth 1 will set the minimum depth, to avoid including the current directory -type d will only find directories -exec will run a command {} contains the path of the found directory If you want to use only builtin shell ...
How to create a file for every directory on a tree?
1,347,356,961,000
For example, I want to find out why monodevelop does depend on systemd. apt-rdepends -r systemd shows all packages that that directly or indirectly depend on systemd: $ apt-rdepends --dotty -r systemd | grep monodevelop "monodevelop" -> "libgnome2.24-cil"; ... debtree monodevelop shows all packages monodevelop depend...
Developed a oneliner for this: $ apt-rdepends --dot -r systemd | perl -ne 'our %chains; if(m!"([^"]+)" -> "([^"]+)"[^"]*;!) { my $c="$2 $chains{$2}"; $chains{$1}=$c; print "$1 $c\n" }' | grep '^monodevelop ' Reading package lists... Done Building dependency tree Reading state information... Done monodevelop li...
How do I display a dependency chain from one package to another?
1,347,356,961,000
Is there a way on unix to print out the file structure, like Bootstrap's getting started page? bootstrap/ ├── css/ │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── bootstrap-theme.css │ ├── bootstrap-theme.min.css ├── js/ │ ├── bootstrap.js │ ├── bootstrap.min.js └── fonts/ ├── glyphicons-halflings-re...
Take a look to tree command. http://mama.indstate.edu/users/ice/tree/ For debian like distro : sudo apt-get install tree
Print out file structure on Unix
1,347,356,961,000
I am wondering if it's possible to output the contents of a tar.gz file using tree without having to extract the contents of the file to a temp directory then using tree with that directory. I know we can see the contents of the file without extracting using tar -tf file.tar.gz And I have simply tried piping this to ...
Custom tree script treeify.py created by Hakril would help to pretty print contents of tgz without extracting [root@bastion ~]# wget https://bitbucket.org/Hakril/treeify/raw/8e732368f64d30ffc4033cbc890164fdf296d9f8/treeify.py [root@bastion ~]# tar -tvf neo4j-enterprise.tar.gz | python treeify.py . ├─ drwxrwxrwx root...
Using tree with tar.gz file without extracting contents
1,347,356,961,000
If I have a text-file with a structured list like this: #linux ##audio ###sequenzer ####qtractor ###drummachine ####hydrogen ##scores ###lilypond ###musescore ##bureau ###kalender ####calcurse ###todo ####tudu How can I print it tree like to the command-line? linux/ ├── audio │   ├── drummachine │   │   └── hydroge...
Use awk to convert the structure to "normal" pathes. linux/ linux/audio/ linux/audio/sequenzer/ linux/audio/sequenzer/qtractor/ linux/audio/drummachine/ linux/audio/drummachine/hydrogen/ ... Then you can use tree --fromfile . to read it: convert_structure.awk: { delete path_arr path = "" level=match($0,/...
Print structured list to command-line (tree like)
1,347,356,961,000
So I'm asking myself why there is the "-R" argument for the "tree" command. The manual says "-R Recursively cross down the tree each level directories ...", but I don't see any difference in the result between those two.
The -R option is only effective in HTML output mode, and is ignored if you don’t also specify a maximum display depth with the -L option. tree -R -L 2 -H . -o tree.html will output the tree to tree.html, and additionally generate subtrees every two levels in OOTree.thml files in each corresponding directory.
Command "tree" vs "tree -R"
1,347,356,961,000
I've been trying to sort output with either tree or find, and end up getting about the same results each time of drilling down to deeper directories before files higher up in the tree. What I'm trying to do is store the directories of interest in a lua table with the directory as the key for sub tables of files. I'm u...
Display the directory names first, then jump in and display only filenames: find . ! -name . -type d -print -exec sh -c 'find "$1" -maxdepth 1 ! -type d' {} {} \;
List directory hierarchy with files before subdirectories
1,347,356,961,000
I tried to install TREE via the sudo apt-get install tree command but nothing but an error happens ("sudo: apt-get: command not found"). How do I fix this?
Distribution A system built on Linux is called a "distribution". Distribution examples: Ubuntu Debian Fedora Arch OpenSuse ... To install a software on a distribution, you have several possibilities: Build the software from source, Install the program with a "package manager". Package manager Almost each distribut...
How do I install TREE when the command line doesn't work?
1,347,356,961,000
I'd like to get a custom output from the tree command, but unlike this question, I don't have a fixed format. I'd like to be able to give the command the format in an argument (for instance perhaps -f=y, -f=yaml,-f=xml,-f=~/myformat.fmt). Obviously this is a huge undertaking, but I feel it would be a good way to get t...
On Debian, Ubuntu, Mint and other distributions using Dpkg and APT to manipulate packages: dpkg -S /path/to/file looks for the installed package containing the specified file, e.g. dpkg -S /usr/bin/tree dpkg -S $(which tree) apt-file search /path/to/file looks for the package in the distribution containing the speci...
Edit tree to output in custom format?
1,347,356,961,000
I tried to combine --dirsfirst and -r, but directories still show up on top, only in reverse alphabetical order. It seems like -r is applied first, which is also indicated by the man pages. Any other ideas of how I would go about sorting the output of tree so that subdirectories are listed after the files?
If you came here looking for this answer (as I did), use: tree --filesfirst Option --filesfirst was added in version 2.0.0 (12/21/2021)
Using `tree`, how do I output files before subdirectories?
1,347,356,961,000
man tree1 states: -info Prints file comments found in .info files. See .INFO FILES below for more information on the format of .info files. and further .INFO FILES .info files are similiar to .gitignore files, if a .info file is found while scanning a directory it is read and added to a stack of .info information....
Example: $ cat .info a.jpg blah blah blih blih *.jpg jpeg picture $ tree --info . ├── a.jpg │   ⎧ blah blah │   ⎩ blih blih ├── a.png ├── b.jpg │   { jpeg picture ├── b.png └── foo.user 0 directories, 5 files (with a TAB preceding the comments per the manual you quoted).
Creating .info files to be used with tree
1,347,356,961,000
I'm searching a large number of text files which are organized in various subdirectories. I can run a command such as grep -lr foobar ./, and I get results like the following: ./dirA/dirA.A/abc.txt ./dirA/dirA.A/def.txt ./dirA/dirA.A/dirA.A.A/ghi.txt ./dirA/dirA.B/jkl.txt ./dirB/mno.txt I would like some way to displ...
I found a solution using a version of tree which is newer than what was installed on my system. Version 1.8.0 of tree (released 11/16/2018) introduced the --fromfile parameter, which reads a directory/file listing from a file (or stdin) rather than the filesystem itself and generates a tree representation: $ grep -rl ...
Display `grep -lr` results as a tree
1,347,356,961,000
In order to store attachments, a /path/to/atts/ directory will have numerous child-directories (product IDs) created (from 1 to ~10,000 or maybe more in the future), and in each of this subdir, 1 to ~10 attachment files will be created. In /path/to/atts/ 1 ├── file1.1 ├── file1.2 └── file1.3 2 └── file2.1...
You can read about the hash tree index used for directories here. A linear array of directory entries isn't great for performance, so a new feature was added to ext3 to provide a faster (but peculiar) balanced tree keyed off a hash of the directory entry name.
'cd' complexity on ext4
1,462,711,091,000
I'm looking for a program that takes the output of iptables -S and converts it to a breadth-first listing. Why? I'm doing some work on a router using VyOS where several layers of tables are pre-installed, so it is difficult to trace back all the rules connect to INPUT, FORWARD, and OUTPUT. As per @JeffSchaller 's [r...
Some time ago I needed to flatten breadth-first the tree of rules of a custom firewall and have them all out on a file. Not VyOS but iptables anyway. I came up with the following script, see if it helps you. Please note that this script requires at least Bash v4 #!/bin/bash - declare -A all_chains=() declare -A queue...
How to convert `iptables -S` output to a breadth-first listing
1,462,711,091,000
I am trying to visually show the tree structure of a directory. I know about the tree command and that works for me, but is there a program that takes the tree command output and makes it a bit more visually appealing? I understand that I could do this manually, but I was just wondering if there was software out that...
Depending on how fancy you want to get, tree already can output directly to HTML format with the -H option (there are other options that affect the HTML output as well): tree -H /path/to/directory /path/to/directory You need to specify the path twice, because -H requires a root (it was designed around creating FTP di...
Make a visually better looking tree [closed]
1,462,711,091,000
I run with tree 1.7.0 tree -PF dat It gives . ├── 0deg/ ├── 105deg/ ├── 120deg/ ├── 135deg/ ├── 150deg/ ├── 15deg/ ├── 165deg/ ├── 180deg/ ├── 210deg/ ├── 240deg/ ├── 270deg/ ├── 300deg/ ├── 30deg/ ├── 330deg/ ├── 360deg/ ├── 45deg/ ├── 60deg/ ├── 75deg/ └── 90deg/ where each folder contains a file [directory-name...
The short answer using tree would be tree -PF *.dat You can also use (As I explained in my comment ) the GNUfind command. find . -type f -name '*.dat' -printf '|__ %P\n' You don't need GNUfind though. You can also use the following which is posix. find . -type f -name '*.dat' -print
Tree with directory name and filenames
1,462,711,091,000
is there a nice way to combine: ls -R | grep "^[.]/" | sed -e "s/:$//" -e "s/[^\/]*\//--/g" -e "s/^/ |/" (displays directory as tree) with du -h ... (for each listed dir) Without installing any extra package, like tree, dutree ?
I think, you should revert the order of du -h with tac and then put some formatting with sed. This one should work for "normal" directory names (without control characters): du -h | tac | sed 's_[^/[:cntrl:]]*/_--_g;s/-/|/' Or use find -exec: find . -type d -exec du -sm {} \; | sed 's_[^/[:cntrl:]]*/_--_g;s/-/|/'
du + tree command (without tree installation)
1,462,711,091,000
How to list files recursively, in alphabetical order and without lines that show exclusively folder names? For example, I can get the following output with tree --dirsfirst -fihan * -o filelist: 00.-ScriptHookV [1.0.1737.0] [128K] 00.-ScriptHookV [1.0.1737.0]/dinput8.dll* [1.2M] 00.-ScriptHookV [1.0.1737.0]/ScriptHo...
Should be pretty portable: find . -type f | sort On the off chance that your input data contains files with new lines in their name, I believe this should handle them better (thanks to Kusalananda for pointing out this possible scenario): find . -type f -print0 | sort -z | tr '\0' '\n'
List files recursively, in alphabetical order and without lines that show exclusively folder names
1,462,711,091,000
Why the last tree is not finding fstab? tree /etc -P fstab --prune /etc └── fstab 0 directories, 1 file . tree /etc -P fsta* --prune /etc └── fstab 0 directories, 1 file . tree /etc -P *stab --prune /etc └── fstab 0 directories, 1 file What is happening here? According to my understanding it should find...
When you use an unquoted globbing pattern on the command line, the shell will try to match it against filenames. If no filename matches the pattern, most shells will keep the unexpanded pattern (zsh would by default complain, as would bash with set -u). You obviously have some file whose name matches *sta*, but not f...
Confused about "tree" not finding a file
1,462,711,091,000
tree shows ... │   ├── template_one_file.sh │   ├── template_sed.sh │   ├── testy.sh │   ├── tmp │   │   ├── file1.html.13567_old │   │   ├── file2.html.13567_old │   │   ├── file3.html.13567_old │   │   └── file4.html.13567_old │   └── use_case_to_add_etc_2_numbers └── vi ├── vim_tips_and_chearsheet └── vi_st...
Use a wildcard: tree -I '*_old' -L 4 Reference: man tree (my emphasis) -I pattern Do not list those files that match the wild-card pattern.
Why does 'tree' command ignore directories but not files
1,462,711,091,000
I tried to use the tree command in a bootable USB Ubuntu environment but it showed that it is not installed so I tried sudo apt install tree, but it didn't work and reported that it was unable to locate package and also said to enable component universe. I don't know what component universe is. How can I fix this?
To enable universe, run sudo add-apt-repository universe Then update the indexes: sudo apt update You’ll be able to install the tree package once that’s done: sudo apt install tree
Tree command package installation?
1,462,711,091,000
I'm using gnuclad to create a tree. The problem is that I'm not able to change the starting date. I'm using the data below, from the default example. #,Nodes,,,,,,,,,,,,, #,Name,Color,Parent,Start,Stop,Icon,Description,[Namechange,When,Description,[Namechange,When,Description,". . . ]]" N,Name here,#f00,,2002/12/01,20...
Here I found the problem. The correct way to insert dates is using dots, e.g., 2012.03.10 and not slashes. The problem was the use of Gnumeric to edit the CSV file.
gnuclad does not change starting date
1,462,711,091,000
I'm attempting to replace a "fenced" block of text with the output from the tree command in linux (specifically in a make file). Here's my input file: some text... [fencetitle] ---- . ├── file1.txt └── test └── file2.txt 1 directory, 2 files ---- some more text... And I'd like to replace the contents with outpu...
You could try something like: sed -n "/\[fencedtitle\]/{:a;N;/----/!ba;N;s/.*\n/$(tree)\n/};p" file But this will be problematic if the output of tree contains characters that are special for regex. If you save the output of tree to a file: tree > my-out Then you can read it in sed without too many problems: sed -n ...
Replace fenced block with output of command in bash
1,462,711,091,000
I would like tree to display the hw files in the sub-directories like this: . ├── exp │   └── hw ├── src │   └── hw.cpp2 └── tmp └── hw.cpp $ /usr/bin/tree --noreport . displays all of the files: . ├── exp │   ├── hi │   └── hw ├── src │   ├── hi.cpp2 │   └── hw.cpp2 ├── ssbuild.bash ├── sslogin.bash └── tmp ...
The tree utility has a specific option, -P, for specifying a pattern that the filenames must match to be part of the output. The type of pattern used with -P is a shell filename globbing pattern, and as such, it needs to be quoted to avoid having the shell expand it on the command line. tree -P 'hw*' . Since your cu...
Tree display hw, hw.cpp & hw.cpp2 in sub-directories
1,462,711,091,000
I want to keep only the last line of tree's output or the file+directory count report. Preferably, with the -a switch. An example output I desire: 585 directories, 37722 files Is this possible with tree?
tail is a standard filter to print last line(s). To print one last line use tail -n 1. tree -a | tail -n 1
tree command to only output file and directory count?
1,462,711,091,000
I learnt that there was a command cloc to count lines of code. Now I wonder if it the file types are accurate? Should I look a the cloc project to know how file types are detected? The reason I wonder is that cloc seems to have false positives if I'm not mistaken when I compare the file types to the tree|ls *.py ther...
If you want to check the number of .py files in your tree to compare it to the number found by cloc, I’d suggest something like find . -type f -name \*.py -printf '1' | wc -c instead.
Statistics for project filestypes [closed]
1,462,711,091,000
What is the situation why ls -l returns a list of subdirectories in the form below? d????????? ? ? ? ? ? Subdirectory A tree launched on that directory returns 0 directories, 0 files for example. The system seems to know the name of the subdirectory but cannot find it. Which missing link confuses ls? Late not...
You have read, but not execute/search permissions to the containing directory. Easy to reproduce with: mkdir -p foo/bar; chmod -x foo; ls -l foo ls: cannot access 'foo/bar': Permission denied total 0 d????????? ? ? ? ? ? bar On Linux and BSD, ls is able to get that it's a directory from the d_type field of...
What does the output `d?????????` in `ls -l` mean? [duplicate]
1,462,711,091,000
Is it possible to use tree to create several output files without being cd ~/ into the directory I want to create a tree file? For example, I have a directory called parent-dir. Inside of parent-dir are subdirectories titled a, b, c to z and one also titled 0-9. Inside of those subdirectories are more subdirectories t...
In zsh: for d (parent-dir/*/*(N/)) (cd -- $d && tree) > output-dir/$d:t.txt
Using 'TREE' for sub-subdirectories
1,462,711,091,000
Which option should be used with tree command line tool to get sort from biggest to smallest? ├── [4.0K] types2 │   └── [ 116] types2.go ├── [4.0K] types3 │   ├── [ 689] types3.go │   └── [ 0] types3.go~ ├── [4.0K] web │   ├── [ 149] index.html │   ├── [ 647] web.go │   └── [ 0] web.go~ ├── [4.0K] wordco...
Even if the tree tool doesn't support sorting by size directly, you can still do it using tree and sort. You can use the following command to list all the files and their paths in the given folder and subfolders with their file size and then use the sort tool to sort them by the second column of tree output (that is t...
How to sort from smallest to biggest with `tree` command line tool?
1,462,711,091,000
I gave the command tree -J to my machine, and this is a portion of the output it gave: { "type": "file", "name": "ca-certificates.conf" }, { "type": "file", "name": "ca-certificates.conf.dpkg...
This is a known bug. Apparently it was fixed yesterday, 2023-05-31. I'm not seeing where in https://gitlab.com/OldManProgrammer/unix-tree/-/commit/84fa3ddff51b30835a0f9c4a9e4c9225970f9aff it was fixed, but this is between you and Steve Baker.
Command "tree -J" returns invalid Json
1,462,711,091,000
I need to draw the tree structure of the following code. cd /; mkdir a b c a/a b/a; cd a; mkdir ../e ../a/f ../b/a/g; cd../b/./; mkdir /a/k a/b ../a/./b /c I know that: cd /; (goes to root) , mkdir creates directories a b c but I can't understand the rest of the line. Any thoughts would be really helpful.
This is written in a confusing manner and I'm assuming comes from a basic linux/unix test. I can explain. It will seem clearer if it is on multiple lines. The ; char means end of a command. The mkdir command can do multiple things with one execution. cd / You will be in / as your current working directory. mkdir a b ...
Tree structures and directories [closed]
1,462,711,091,000
I'm in a directory where running tree command produces something like this: ├── directory1 │  └── image_sequence │  ├── image.0001.jpg │  ├── image.0002.jpg │  ├── image.0003.jpg │  ├── image.0004.jpg │  ├── image.0005.jpg │  └── image.0006.jpg │  └── directory2 ├── somefile.ext ...
Try this: tree | sed '/\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 image\.[0-9]\+\.jpg/d; s/\(\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 image\.\)[0-9]\+\(\.jpg\)/\1####\2/' The first /.../d; deletes all lines containing ├── image.[0-9]+.jpg (pseudo-pattern) entries The second s/.../\1####\2/ replaces the last line └── image.[0-...
How to shorten image sequence output in tree command?
1,462,711,091,000
I am tired of using the -C with the tree all the time. I would like to tweak the tree to colorize files and directories to its automatic behavior so that I don't have to type the -C flag all the time. How to enable automatically colorize the output of tree without using -C flag in bash all the time?
echo "alias tree='tree -C'" >>/etc/profile.d/tree-C.sh Then logout and log back in. Putting it in /etc/profile.d makes this shortcut available to all users on the machine so that it'll work even if you change user accounts (su/sudo)
How to enable automatically colorize the output of tree without using -C flag in bash all the time?
1,462,711,091,000
I have a folder with symlinks which are pointing to other folders, how can i recursively look into those folders? I would like to do a grep on those results to search for matches. doing tree will only list the symlink as files.
You can use find with the -L option, e.g., find -L . -type f -exec grep foo {} \; That makes find follow symbolic links. Quoting POSIX: -L Cause the file information and file type evaluated for each symbolic link encountered as a path operand on the command line or encountered during the traversal of a file h...
Tree/Find command on symlinks
1,462,711,091,000
I just installed tree via sudo apt-get install tree and my terminal suddenly decided to update grub. Last week, I installed tree, and a similar thing happened. However, when I restarted my PC later that night it booted into a window displaying Grub _ and didn't change. Eventually I reinstalled my OS (I'm on WattOS, ...
Narrowing Down of Errors I see lots of things that need attention before we worry about grub 26 packages (at least) need removed. 174 packages need upgraded. Grub needs a bit of investigation and a possible fix as oldfred's comment suggests. We need to knock out the small steps (1 and 2) to keep from possibly having...
Installing tree installed grub - is it something to worry about?
1,462,711,091,000
When you generate a tree for a large directory base with innumerable sub-directories and associated files, with -a option, often you get a large file with thousands of lines. While traversing the tree depicted within this file, it often becomes difficult to keep track of which directory you are in at any given point i...
The tree utility on Linux has a -f option that lists each directory entry with its relative pathname: $ tree -f ufw ufw ├── ufw/after6.rules ├── ufw/after.init ├── ufw/after.rules ├── ufw/applications.d │   ├── ufw/applications.d/cups │   ├── ufw/applications.d/openssh-server │   └── ufw/applications.d/postfix ├── ufw...
tree: Is there a way to maintain visibility of outer level directory labels when scrolling?
1,462,711,091,000
I want to find user, size, modified date and full file path of all files in sub-directories starting from a dir. I have got to following so far: nohup sudo \ tree /work/mydir \ -sufiD \ --noreport \ --timefmt="%Y-%m-%d" | \ sed -e 's/ \+/ /g' -e 's/\[//g' -e 's/\]//g' -e 's/\.\///g' -e 's/ /|/g' | \ tail -n+2 \ > usa...
You can use -ls in find to get the owner size, and modification time: find . -type f -size +10M -ls
How to find files greater than a size in linux [duplicate]
1,430,915,124,000
I have a device under test (DUT) and I measure its power usage the using a Power Analyzer Datalogger using the data from /dev/ttyUSB0. The problem is that the DUT is now remotely from the workstation I used to gather data with, but in the same network, I need to use a 2nd PC which is directly connected via USB to the...
socat might work here. On the 2nd PC you could let socat listen for data on /dev/ttyUSB0 and serve it to a tcp port, e.g: socat /dev/ttyUSB0,raw,echo=0 tcp-listen:8888,reuseaddr Then on 1st PC you can connect to 2nd PC with socat and provide the data on a pseudo terminal /dev/ttyVUSB0 for your application: socat PTY,...
How can I set up a "USB proxy" for /dev/ttyUSB0 over the network?
1,430,915,124,000
I have a small LED matrix controlled by a display driver that accepts serial commands to update the display. I'm successfully controlling it via node with the node serial package, however I'd like to be able to update it with echo so that I can control it earlier in the boot up process with a shell script. To start te...
I was able to configure the serial port so echo behaved like screen. Here are my settings: stty -F /dev/ttyUSB0 115200 raw -echo -echoe -echok -echoctl -echoke And to echo: echo -e -n 'command_here\r' > /dev/ttyUSB0
Sending serial commands with echo vs screen session
1,430,915,124,000
I am trying to set up getty to log in over serial (mainly as an experiment). With almost any configuration, the same thing happens. If my default shell is bash, I get this message after I log in: -bash: cannot set terminal process group (15297): Inappropriate ioctl for device -bash: no job control in this shell and ...
It's not the commands but the environment in which they run that is the difference. Normally getty is spawned directly from the system service manager (init) – both with systemd where it is a .service, and in the SysV world where it has an inittab entry (and not an init.d script!). This has several differences from be...
job control doesn't work when I try to set up getty over serial
1,430,915,124,000
If I connect my ESP32 to my Ubuntu ( 22.04 ) by USB it is available in /dev/ttyUSB0. If I run a call - for example sudo ampy --port /dev/ttyUSB0 ls the error message apears Traceback (most recent call last): File "/usr/local/bin/ampy", line 8, in <module> sys.exit(cli()) File "/usr/lib/python3/dist-packages/cl...
I have the exact same issue with a USB→serial converter. Worked fine on 20.04 (even 21.10), and with 22.04 I see the device appearing for a short time, then 1 or 2 seconds later, disappears. dmesg output: [ 2713.068159] usb 1-2: new full-speed USB device number 32 using xhci_hcd [ 2713.222910] usb 1-2: New USB device ...
/dev/ttyUSB0 is available but after try to call it's gone
1,430,915,124,000
I have a CH341a Programmer and when I plug it into a usb port everything seems to be working except it doesn't get assigned to a Device Path (eg /dev/ttyUSB0). Does anyone have any clue as to why this might be happening, or how to resolve this issue? Here are some of the things I've done to troubleshoot. lsusb Bus 002...
Your device isn't being assigned a serial device path because it's not a serial port. From your lsusb output, we see: Bus 001 Device 004: ID 1a86:5512 QinHeng Electronics CH341 in EPP/MEM/I2C mode, EPP/I2C adapter The key part is in EPP/MEM/I2C mode. The device is not configured as a UART; if it were, we would see: B...
Why isn't my CH341a Device Getting Assigned a Device Path (/dev/ttyUSB0)
1,430,915,124,000
I bought an USBASP 2.0 programmer and hooked it up, I cannot see any port created by the programmer. What I expect is USBtty0 in /dev To fix it I have restarted UDEV and tried other UDEV configurations but it doesn't show. uname Linux Puc 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_6...
I don't think it's supposed to. If I remember correctly, USBasp works with custom control transfers, and e.g. avrdude looks it up from /dev/bus/usb by the vendor and product IDs and ID strings. With avrdude, something like this should work, or complain that it can't find a USB device with the correct IDs: avrdude -P u...
USBasp not creating ttyUSB0